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

QTextDocument markdown parsing

    XMLWordPrintable

    Details

    • Type: Suggestion
    • Status: Closed
    • Priority: Not Evaluated
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: 5.14.0 Alpha
    • Component/s: GUI: Text handling
    • Labels:
      None
    • Commits:
      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

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

            Activity

              People

              Assignee:
              srutledg Shawn Rutledge
              Reporter:
              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