Details
-
Suggestion
-
Resolution: Unresolved
-
Not Evaluated
-
None
-
None
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
- relates to
-
QTBUG-75662 handle CSS styling for markdown format in QTextDocument / QTextBrowser
- Reported