Details
-
Bug
-
Resolution: Fixed
-
P2: Important
-
5.15.2
-
None
-
-
ca4774131 (dev), 106442586 (6.7), 0281005a7 (dev), 662dbcb8a (6.7)
Description
QTextMarkdownWriter fails to escape special characters at the beginnings of blocks, most notably '-', '*', '+' and '#' and generally fails to escape special characters like '\' and '`', causing ordinary characters to be treated as markup when reading back the generated markdown code.
The failure to escape initial characters in a block is surprising, because there is code to escape the first character when wrapping text, which is a much less common case (see the static function maybeEscapeFirstChar and where it is called).
The text "+ and - are arithmetic operations" is written out verbatim, so when it is read back in as markdown, it shows as a list item:
- and - are arithmetic operations
Similarly, when the text "# is next to 0 on your phone keypad" is read back as markdown, it is treated as a heading and looks like this:
is next to 0 on your phone keypad
The text "Use two backslashes <backslash><backslash> to separate fields." (with <backslash> replaced by a backslash character - ironically, the Jira visual editor does not allow me to enter two backslashes) is exported verbatim and when read back becomes:
Use two backslashes \ to separate fields.
I have tested this with Qt 5.15.2, but from looking at the source code, there seems to be no change since then, so I expect this to still be broken in the current Qt6 releases.
Attachments
Issue Links
- duplicates
-
QTBUG-96051 markdown writer: in a table cell ending with backslash, it's not escaped
- Closed
For Gerrit Dashboard: QTBUG-122083 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
544489,10 | QTextMarkdownWriter: escape all backslashes | dev | qt/qtbase | Status: MERGED | +2 | 0 |
544490,13 | QTextMarkdownWriter: escape special characters (line or word prefix) | dev | qt/qtbase | Status: MERGED | +2 | 0 |
545337,2 | QTextMarkdownWriter: escape special characters (line or word prefix) | 6.7 | qt/qtbase | Status: MERGED | +2 | 0 |
551275,5 | QTextMarkdownWriter: escape all backslashes | 6.7 | qt/qtbase | Status: MERGED | +2 | 0 |