Bug 441541 - Comments break preview
Summary: Comments break preview
Status: RESOLVED UPSTREAM
Alias: None
Product: markdownpart
Classification: Frameworks and Libraries
Component: general (other bugs)
Version First Reported In: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Friedrich W. H. Kossebau
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-08-25 18:50 UTC by geisserml
Modified: 2024-05-13 12:14 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
kmarkdownwebview blank preview (78.37 KB, image/png)
2021-08-26 11:40 UTC, geisserml
Details
QOwnNotes Markdown Preview (218.57 KB, image/png)
2021-11-21 16:15 UTC, geisserml
Details

Note You need to log in before you can comment on or make changes to this bug.
Description geisserml 2021-08-25 18:50:51 UTC
SUMMARY
I usually put up a comment on top of my Markdown files, for copyright and licensing information. However, this seems to break the markdownpart preview generator.
In Markdown, commens are indicated by `<!--  -->`, with the comment text placed in between the hyphens.

Example:
```markdown
<!-- SPDX-FileCopyrightText: 2021 Manuel Geißer <geisserml@gmail.com> -->
<!-- SPDX-License-Identifier: CC-BY-4.0 -->

# Test

Description

## Sec 1

* a
* b

## Sec 2

* c
* d
```

STEPS TO REPRODUCE
1. Paste the above example into Kate or KDevelop
2. Open the Preview panel
3. Click the play button
4. View result
5. Remove the two comment lines
6. View result

OBSERVED RESULT
With the comments, no preview is visible, only a single dot.
Without the comments, the preview looks correct.

EXPECTED RESULT
The preview should always represent the markdown code correctly, even if there is a comment.

SOFTWARE/OS VERSIONS
Operating System: KDE neon 5.22
KDE Plasma Version: 5.22.4
KDE Frameworks Version: 5.85.0
Qt Version: 5.15.3
Kernel Version: 5.11.0-27-generic (64-bit)
Graphics Platform: Wayland

ADDITIONAL INFORMATION
The described syntax works correctly with Github preview.
Comment 1 Friedrich W. H. Kossebau 2021-08-25 20:26:44 UTC
I can confirm this behaviour, Qt 5.15.2 (openSUSE TW).

The markdownpart itself is only a wrapper around the markdown support in Qt's QTextDocument.  See also info in
https://invent.kde.org/utilities/markdownpart/-/blob/master/README.md

So this need reporting to and fixing in Qt itself, there is nothing we can do here without implementing a markdown parser ourselves or switching to another engine.
Comment 2 geisserml 2021-08-26 10:37:05 UTC
Thanks for the response.
Will you file an issue at bugreports.qt.io or should I do this?
After a quick look at the existing bug reports, it seems that the QTextDocument markdown engine is not particularly sophisticated and has lots of known issues.

Last time I tried, I got equally disappointing results with the other kde markdown previewer, kmarkdownwebview. (I don't remeber anymore whether it was also the comments issue or whether it just didn't work at all.)
Comment 3 geisserml 2021-08-26 10:47:38 UTC
Now I also tried the Okular markdown support, but it's somewhat of a joke - it just shows the raw text for me. Is this expected?
Comment 4 geisserml 2021-08-26 10:49:27 UTC
Ah, actually it works in Okular when removing the comment lines. Similar issue, apparently.
Comment 5 Friedrich W. H. Kossebau 2021-08-26 10:55:24 UTC
(In reply to Manuel Geißer from comment #2)
> Last time I tried, I got equally disappointing results with the other kde
> markdown previewer, kmarkdownwebview. (I don't remeber anymore whether it
> was also the comments issue or whether it just didn't work at all.)

I just gave kmarkdownwebview a try, and it could cope at least with the example given here. Not working at all was not a bug I can remember about that one, usually it was issues with having it properly configured to be the part to use, or e.g. kate failing to yet detect the markdown format of a file for which preview was wanted.

Sorry, myself out of business here when it comes to markdown, and the markdownpart is only "community-maintained"  now, so no-one actively driving ti forward, but at best fixing things where easily possible.

This needs new human resources :)

> Will you file an issue at bugreports.qt.io or should I do this?

Please do, as I have no own motivation here.

> After a quick look at the existing bug reports, it seems that the
> QTextDocument markdown engine is not particularly sophisticated and has lots
> of known issues.

Sorry to hear that. The disadvantage of relying on an upstream project, even more with the locked situation around Qt 5.15 :/

In a perfect world someone would fork the markdown parsing out of Qt and drive it forwards in an indeoendant project. Using QTextDocument itself for rendering as before should be fine though.
Comment 6 geisserml 2021-08-26 11:35:06 UTC
> I just gave kmarkdownwebview a try, and it could cope at least with the example 
> given here. Not working at all was not a bug I can remember about that one, 
> usually it was issues with having it properly configured to be the part to use, 
> or e.g. kate failing to yet detect the markdown format of a file for which 
> preview was wanted.
Actually I double-checked everything was configured correctly by that time, but I'll try kmarkdownwebview again.
Comment 7 geisserml 2021-08-26 11:39:25 UTC
Nope, the issue with kmarkdownwebview still persits:
- uninstalled markdownpart
- installed kmarkdownwebview
- configured the file association for embedding
- opened file
- preview is blank white, no text visible

Should I open a new bug report at kmarkdownwebview?
Comment 8 geisserml 2021-08-26 11:40:43 UTC
Created attachment 141061 [details]
kmarkdownwebview blank preview
Comment 9 Friedrich W. H. Kossebau 2021-08-26 11:59:23 UTC
(In reply to Manuel Geißer from comment #7)
> Nope, the issue with kmarkdownwebview still persits:
> - uninstalled markdownpart
> - installed kmarkdownwebview
> - configured the file association for embedding
> - opened file
> - preview is blank white, no text visible

Sad, thanks for sharing, mental note made. No idea what could be wrong there and thus where to start.

> Should I open a new bug report at kmarkdownwebview?

Thanks for the offer, just myself as author have abandoned kmarkdownwebview, as the technology used internally is rather insane from a pure design POV, and also might have lots of loop holes for attacks, so being insecure. 
So any new bug report might be only for the records, until one point in time someone might decide to revive it for whatever reasons.

You might want to get in contact with other potential developers and heavy Markdown users to form some critical mass to get active development here going. No idea how to do that best, sorry :) I was once surprised there was 0 support, that's why I had hacked up the preview plugin and kmarkdownwebview in the beginning, but then found there are bigger blockers to make this perfect (starting with embedded images which need proper internal redirection to load), and I had not enough own need to invest more, so actually even once suggested to remove the preview plugin again, but others kept it in -> https://phabricator.kde.org/D16668 So I am out of responsibility here :)
Comment 10 geisserml 2021-08-26 12:31:16 UTC
> No idea what could be wrong there
Maybe it's due to my theme? The text colour is plain white, so if the background colour is not taken into account, but the text colour is, then it would be white-on-white and the result would be explainable.

Thanks for the help and the time you have put into creating markdownpart and kmarkdownwebview. Apparently markdown preview generation is a complex subject and I can understand you don't want to work on it anymore.
Comment 11 geisserml 2021-11-21 16:09:48 UTC
> You might want to get in contact with other potential developers and heavy Markdown users
> to form some critical mass to get active development here going.

I just found out there is a program called QOwnNotes [1], which offers an excellent markdown preview.
Maybe it would be possible to work together with the QOwnNotes developers and make that preview generator available to KDE Apps?

[1] https://github.com/pbek/QOwnNotes
Comment 12 geisserml 2021-11-21 16:15:07 UTC
Created attachment 143806 [details]
QOwnNotes Markdown Preview
Comment 13 Andrew 2024-05-13 12:14:31 UTC
(In reply to Friedrich W. H. Kossebau from comment #9)
> there are bigger blockers
> to make this perfect (starting with embedded images which need proper
> internal redirection to load)

Is it also related to external images?
Pictures described like these are not shown for me:

    [![SOMEPROJ](https://raw.githubusercontent.com/someproject/master/.github/banner.svg)](#readme)