diff --git a/src/CodeKeeper/keeperFunc/notesFunc.cpp b/src/CodeKeeper/keeperFunc/notesFunc.cpp index 6594b646..5e6589c9 100644 --- a/src/CodeKeeper/keeperFunc/notesFunc.cpp +++ b/src/CodeKeeper/keeperFunc/notesFunc.cpp @@ -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(userdata); + QString htmlStr(QString::fromUtf8(reinterpret_cast(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()