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

Request for MarkdownSyntaxHighlighter QML type

    XMLWordPrintable

Details

    Description

      Background:
      Qt Creator uses QSyntaxHighlighter for doing the styling as Markdown support in Qt eventually transforms the Markdown into a QTextDocument, code is at:
      https://code.qt.io/cgit/qt-creator/qt-creator.git/tree/src/libs/utils/stringutils.cpp#n573

      It would be nice to be able to control MD Text rendering on the QML side as well. For example, provide a way to customize the headings.

      Why?
      Design team might define these for the rest of the UI – and then one can't obey the rules in this case – which is why one might want to customize the MD Text rendering in the application.

      Suggestion:
      If the styling can be done with the QSyntaxHighlighter, then it would be possible to expose such with some convenient QFont properties for each of the body and heading levels and one could instantiate a "MarkDownSyntaxHightligher", set its properties and then apply it to the TextArea's document.

      MarkdownSyntaxHighlighter {
      
         textDocument: textArea.textDocument  
      
         body { // QFont – we can conveniently use a group property here or assign a completely different QFont
      
            pixelSize: 10
      
         }
      
         heading1 {
      
            pixelSize: 20
      
            weight: 700 // bold: true
      
         }
      
         heading2 {
      
            pixelSize: 16
      
            weight: 600
      
         }
      
         … etc
      
      }
      
      TextArea {
      
          Id: textArea
      
          textFormat: Text.MarkdownText
      
      }
      

      Additional requirements/ideas:
      Properties that are on the class would
      a) be determined by the kind of rendered content
      b) changes to the properties would be reflected instantly.

      Performance-wise, some large documents may take a while to reformat so some smarts should be taken internally to ensure not too many re-layouts when the properties are changed, and to utilize partial view updates where available.

      Attachments

        Issue Links

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

          Activity

            People

              esabraha Eskil Abrahamsen Blomfeldt
              foxxx Tuukka Kettunen
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes