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

QTextDocument markdown parsing

    XMLWordPrintable

Details

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

    Description

      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.

      Attachments

        Issue Links

          For Gerrit Dashboard: QTBUG-72349
          # Subject Branch Project Status CR V

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes