Bug 431416

Summary: Markdown text not displayed after unclosed HTML tag.
Product: [Frameworks and Libraries] markdownpart Reporter: Jan Felix Langenbach <JanFelix.Langenbach>
Component: generalAssignee: Friedrich W. H. Kossebau <kossebau>
Status: RESOLVED UPSTREAM    
Severity: normal    
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Manjaro   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: Screenshot of Issue

Description Jan Felix Langenbach 2021-01-11 03:02:47 UTC
Created attachment 134727 [details]
Screenshot of Issue

SUMMARY
When a markdown document contains a raw HTML tag (e.g. <p>) that is neither self-closing (<p />) nor followed by a closing tag (</p>), all text and headings after this point are not displayed in the preview. Only very few constructs are displayed at all, including the contents of fenced or indented code blocks and the bullet points of ordered and unordered lists, but not the actual list items.

This even happens when the offending tag is enclosed in another properly closed tag like <div>...</div> or when it is commented out using <!-- ... -->. The latter seems particularly strange to me.

STEPS TO REPRODUCE
1. Create a markdown file containing the following:

    # Before Tag
    Text before tag.

    <p>

    # After Tag
    Text after tag.
    ```
    code after tag
    ```

2. Display the file in markdownpart, i.e. using the document preview of Kate.

OBSERVED RESULT
The heading ”After Tag” and the text “Text after tag.” is not displayed. See the attachment for a screenshot.

EXPECTED RESULT
The part of the document after the unclosed tag is rendered like the part before the tag.

SOFTWARE/OS VERSIONS
Linux Version: Manjaro Linux 20.2.1
KDE Plasma Version: 5.20.4
KDE Frameworks Version: 5.77.0
Qt Version: 5.15.2
Comment 1 Friedrich W. H. Kossebau 2021-01-17 21:41:43 UTC
Thanks for the report. Sadly this is nothing we can do about "by design", as markdownpart delegates all the hard work to Qt' QTextDocument and its markdown support. See https://doc.qt.io/qt-5/qtextdocument.html#setMarkdown and https://invent.kde.org/utilities/markdownpart/-/blob/master/src/markdownpart.cpp#L186

Sadly so far it is unclear whether there will be further FLOSS releases of Qt 5.15 or when KDE software will go Qt6 (possibly once Qt 6.2 is out this summer), so the effect of reporting that bug to Qt is unclear for now.

If this bug annoys you, a workaround might be to use the (though now deprecated) kmarkdownwebview kpart instead, if Manjaro still holds that around (see https://invent.kde.org/utilities/kmarkdownwebview/)