Skip to content

Commit

Permalink
Added export to HTML
Browse files Browse the repository at this point in the history
  • Loading branch information
Nighty3098 committed May 5, 2024
1 parent 265470d commit c50078d
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/CodeKeeper/keeperFunc/notesFunc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,31 @@ void MainWindow::exportNoteToHtml()
QString filePath = fileSystemModel->filePath(selectedIndex);
qDebug() << "File Path: " << filePath;

QFile markdownFile(filePath);
QString str = QFileDialog::getSaveFileName(0, "Enter filename");
QString html_file = str + ".html";

QString md = noteEdit->toPlainText();

QString html;
md_html(
md.toUtf8().constData(), md.length(),
[](const MD_CHAR *html, MD_SIZE html_size, void *userdata) {
QString *htmlPtr = static_cast<QString *>(userdata);
QString htmlStr(QString::fromUtf8(reinterpret_cast<const char *>(html), html_size));
*htmlPtr += htmlStr;
},
&html, 0, 0);

QFile file(html_file);
if (file.open(QIODevice::WriteOnly)) {
QTextStream stream(&file);
stream << html;
file.close();
qDebug() << "File saved successfully at" << filePath;
} else {
qDebug() << "Error", "Failed to open file for writing.";
}
// qDebug() << html;
}

void MainWindow::loadNotes()
Expand Down

0 comments on commit c50078d

Please sign in to comment.