Created attachment 170496 [details] Test markdown file and its PNG preview ISSUE ****** Opening markdown files in Okular doesn't render correctly single linebreaks (it shows double linebreaks though), e.g. (indent only added here for the report clarity's sake): First Item Second Item Third Item Fourth Item Will be displayed as: First Item Second Item Third Item Fourth Item Full test file and PNG preview attached SOFTWARE/OS VERSIONS ******************** OS: Linux Mint 21 (Ubuntu 22.04 based). No difference whether using: - OS repo installation * Okular 21.12.3 * KDE Frameworks Version: 5.92.0-0ubuntu1 * Qt Version: 5.15.3 - Flatpak install * Okular 24.05.1 * KDE Frameworks Version: 6.2.0 * Qt Version: 6.6.3
Are you speaking about the things under ### 1. Without bullet point ? That is expected [to the degree markdown is terrible and doesn't have an specification], see https://umemotoctrl.github.io/mdpjs/ 6 out of 7 markdown rendering engines render it as a single line.
Thank you for noting this. So it is not a bug indeed and more of a feature request (not sure if there is room for this here). I was actually under the impression it was a bug due to the fact all the places I have been editing markdown (Joplin, Zotero, Typora as desktop editors, or websites such as popular software forges) are actually following as a base a common spec called CommonMark (sometimes referred-to as "Github-flavoured"). It seems to me relatively widespread, even if not the unique path as you demonstrated. Would it make sense to integrate this one to Okular (implementations of it already exist in a bunch of languages)? https://spec.commonmark.org/ https://github.com/commonmark/commonmark-spec/wiki/List-of-CommonMark-Implementations
(In reply to machinedreamcatcher from comment #2) > Thank you for noting this. So it is not a bug indeed and more of a feature > request (not sure if there is room for this here). > > I was actually under the impression it was a bug due to the fact all the > places I have been editing markdown (Joplin, Zotero, Typora as desktop > editors, or websites such as popular software forges) are actually following > as a base a common spec called CommonMark (sometimes referred-to as > "Github-flavoured"). It seems to me relatively widespread, even if not the > unique path as you demonstrated. > > Would it make sense to integrate this one to Okular (implementations of it > already exist in a bunch of languages)? > https://spec.commonmark.org/ > https://github.com/commonmark/commonmark-spec/wiki/List-of-CommonMark- > Implementations I do think that - at some point - it could make sense to switch Okular from libdiscount to Qt's recently-ish gained markdown support (iirc based upon md4c) but don't hold your breath for it. Will happily review patches though.
> (Joplin, Zotero, Typora as desktop editors, or websites such as popular software forges) are actually following as a base a common spec called CommonMark (sometimes referred-to as "Github-flavoured"). It seems to me relatively widespread, even if not the unique path as you demonstrated. After further research, the CommonMark spec alone is not enough to cover that linebreak issue, as show this page: https://markdown-it.github.io ("CommonMark strict" does not convert newlines in paragraphs as linebreaks, but checking the extra feature "breaks" would do it). In the section dedicated to soft and hard breaks, [the specs say](https://spec.commonmark.org/0.31.2/#example-649) that `a renderer may also provide an option to render soft line breaks as hard line breaks.` So the softwares I mentionned earlier may be using CommonMark-based markdown rendered together with extra-features, in particular for linebreak. But any CommonMark-based renderer is supposed to allow forcing hard linebreaks by adding a backslash OR 2 spaces or more at the end of a line. As for Discount, it also implements a way to force hard linebreak [since version 2.1.5a](https://www.pell.portland.or.us/~orc/Code/discount/#v2.1.5a) (and it works at least from Okular 21.12.3): `[support for github flavored markdown] input methods that put hardbreaks (== two spaces) at the end of every input line. The bahavior of linebreaks in Markdown has actually is being [subject to debate](https://talk.commonmark.org/search?q=line%20break), and personnally I would rather have the option to consider newline as linebreak, ideally within the same paragraph. > I do think that - at some point - it could make sense to switch Okular from libdiscount to Qt's recently-ish gained markdown support (iirc based upon md4c) but don't hold your breath for it. Will happily review patches though. Thank you for the feedback. [According to MD4C](https://github.com/mity/md4c?tab=readme-ov-file#links-to-related-projects), QT do use their implementation. MD4C has CommonMark and Github-flavour, as well as extra optional features, potentially the one regarding linebreaks. QT implements a strict CommonMark rendered as well a Github-flavoured one (according to the parameters which is set when using the method). Markdown-related methods seems to be implemented in `QTextDocument` & `QTextEdit` classes. Are those related to the former what you had in mind ? https://docs.w3cub.com/qt/qtextdocument#setMarkdown https://docs.w3cub.com/qt/qtextdocument#toMarkdown While I have never worked on a C++/QT/KDE project so far, it could be a starting point... This is not something I could work on with a high priority either, but I quickly checked the code and I guess I would have to focus on that folder : https://invent.kde.org/graphics/okular/-/tree/master/generators/markdown?ref_type=heads Would you have in mind: 1. Where in the code is libmarkdown (Discount) being called so far ? I could see mentions of it in what seem the build instructions or as comments in `/generators/markdown/converter.cpp`, but could not spot an actual call to the library. 2. Is the Markdown class (in converter.cpp) used to both render view and generate file ? In that case, the general markdown ouput string would be the one returned at the following line ? https://invent.kde.org/graphics/okular/-/blob/master/generators/markdown/converter.cpp?ref_type=heads#L177 Also, should QT/MD4C Markdown renderer be implemented as the new and only markdown backend, or should it be optional and offered as an alternative backend to Discount in the [configuration window](https://docs.kde.org/stable5/en/okular/okular/configure-backends.html)? Not sure whether this is feasible with QT, but ideally the config panel would offer optional markdown features included in MD4C. PS: could this bug report be moved to the Request section?
(In reply to machinedreamcatcher from comment #4) > > I do think that - at some point - it could make sense to switch Okular from libdiscount to Qt's recently-ish gained markdown support (iirc based upon md4c) but don't hold your breath for it. Will happily review patches though. > > Markdown-related methods seems to be implemented in `QTextDocument` & > `QTextEdit` classes. Are those related to the former what you had in mind ? > https://docs.w3cub.com/qt/qtextdocument#setMarkdown > https://docs.w3cub.com/qt/qtextdocument#toMarkdown Yep. something like the setMarkdown could be a way > https://invent.kde.org/graphics/okular/-/tree/master/generators/ > markdown?ref_type=heads Correct. > Would you have in mind: > 1. Where in the code is libmarkdown (Discount) being called so far ? I could > see mentions of it in what seem the build instructions or as comments in > `/generators/markdown/converter.cpp`, but could not spot an actual call to > the library. It is in the convertOpenFile function in that file it is called that all calls to libdiscount is, iirc. > 2. Is the Markdown class (in converter.cpp) used to both render view and > generate file ? Okular has a class of generators that just converts input to a QTextDocument. This is one of them, so it is basically done once a QTextDocument is generated. > Also, should QT/MD4C Markdown renderer be implemented as the new and only > markdown backend, or should it be optional and offered as an alternative > backend to Discount in the [configuration > window](https://docs.kde.org/stable5/en/okular/okular/configure-backends. > html)? I think a first approximation would be to just replace the current one.
(In reply to Sune Vuorela from comment #5) > > Also, should QT/MD4C Markdown renderer be implemented as the new and only > > markdown backend, or should it be optional and offered as an alternative > > backend to Discount in the [configuration > > window](https://docs.kde.org/stable5/en/okular/okular/configure-backends. > > html)? > > I think a first approximation would be to just replace the current one. Please also note that we at some point need to evaluate if the change is worth it, but it is probably easier to do if we have a working implementation. We will likely get some bugs and features swapped out for another set of bugs and features by doing this. After all, our current users have probably gotten used to the current bugs and (mis)features.
Gentoo would be happy if you drop libdiscount: it needs patching to work with modern compilers https://bugs.gentoo.org/904275 https://bugs.gentoo.org/938699 and upstream that doesn't want to deal with modern compilers. https://github.com/Orc/discount/issues/283
Why is gentoo using old versions of discount?
(In reply to Albert Astals Cid from comment #8) > Why is gentoo using old versions of discount? # Ben Kohler <bkohler@gentoo.org> (2023-01-30) # Breaks too many revdeps for now At least okular-22.12 was one of the broken dependencies. Apparently we haven't revisited that decision since.