Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-72349

QTextDocument markdown parsing

XMLWordPrintable

    • Icon: Suggestion Suggestion
    • Resolution: Done
    • Icon: Not Evaluated Not Evaluated
    • 5.14.0 Alpha
    • None
    • GUI: Text handling
    • None
    • 65314b6ce88cdbb28a22be0cab9856ec9bc9604b (qt/qtbase/dev)

      It would be nice to have if qml Text/Label could parse github style markdown formatted text via textFormat: Text.GithubFlavoredMarkdownText

      Currently to get qml Text/Label into displaying any markup languages is to use textFormat: StyledText and pass processed html to it.

      Simplified example for cmark:

      #include <cmark.h>
      QString CMarkSingleton::mdStringToHtml(const QString &t_markdown)
      {
        const QByteArray tmpData = t_markdown.toUtf8();
        return QString::fromUtf8(cmark_markdown_to_html(tmpData.constData(), tmpData.size(), CMARK_OPT_DEFAULT));
      }
      

      (qmlRegisterSingletonType... etc.)
      A CMarkLabel.qml that calls CMarkSingleton.mdStringToHtml(...) and sets textFormat to StyledText will do the rest.
      This works but has the limitations of StyledText (using RichText for Label looks totally out of place).
      OTOH: Using webengine just to display XYZmarkup->html texts is not worth the cost.

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            srutledg Shawn Rutledge
            scientist_st Samuel Stirtzel
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes