Skip to content

Fix strikethrough rendering in markdown converter

Previously the <del> tag that Discount emits would be removed by Qt since it's not in the subset of HTML that it understands. It does know about <s> though, so replace <del> with <s> to render strikethroughs correctly.

Note that I couldn't get Okular to build locally (PEBCAK issue) so I split out this file to debug it. I've tested against http://daringfireball.net/projects/downloads/MarkdownTest_1.0.zip and https://github.com/Orc/discount/tree/ff866f73d4b45c1a8581fc7c81dd2f568aefdfd8/tests/data and the only difference is that trailing whitespace is now trimmed from the end of a line:

8c8
< <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Dashes:</p>
---
> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Dashes: </p>

A quick search suggests this isn't a problem though https://stackoverflow.com/a/27026403:

Within block tags (i.e. <p>, <h1>, <div>, ...) spaces as well as line breaks at the beginning or end of the tags should always be ignored (i.e. <p>test</p> should look the same as <p> test </p>).

I also tried https://doc.qt.io/qt-5/qtextdocument.html#setMarkdown which solves the strikethrough problem, though there are many visible differences with that approach. Most notably, everything is squashed together and code blocks lose their formatting.

Merge request reports

Loading