Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.6.2
-
None
Description
Hello,
While developing my block editor (Daino Notes) I came across your QML texteditor example (https://doc.qt.io/qt-6/qtquickcontrols-texteditor-example.html). While very useful, there is a clear bug when converting a QTextDocument with multiple formating options applied to Markdown.
For example, when formatting a selection using both underline and italic, the HTML shows ok, but upon converting the QTextDocument doc to Markdown via doc.toMarkdown() this is the output:
"*_some*_"
While it should be:
"*_some_*"
Same with strike-through and bold:
"**~~some**~~"
While it should be:
"**~~some~~**"
I thought I might be able to convert the HTML using a third party library (https://github.com/tim-gromeyer/html2md) but the HTML produced by QTextDocument doesn't seem standard, therefore, the third party library doesn't recognize the format.
Here's a very simple code to reproduce this bug:
#include <QApplication> #include <QString> #include <QTextDocument>int main(int argc, char *argv[]) { QApplication app(argc, argv); QString html = "<html><body><u><i>something</i></u></body></html>"; QTextDocument textDoc; textDoc.setHtml(html); qDebug() << textDoc.toMarkdown(); return app.exec(); }
Which prints the following wrong string:
"*_something*_\n\n"
Where it should be:
"*_something_*\n\n"
I would love if you could fix it soon, as it will prevent me from working on a weird hack around it. Thanks!