[okular] [Bug 488497] Markdown not respecting linebreak

2024-06-17 Thread bugzilla_noreply
https://bugs.kde.org/show_bug.cgi?id=488497

machinedreamcatc...@temp752.ynh.fr changed:

   What|Removed |Added

 Status|REOPENED|NEEDSINFO
 Resolution|--- |NOT A BUG

--- Comment #4 from machinedreamcatc...@temp752.ynh.fr ---
> (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?

-- 
You are receiving this mail because:
You are watching all bug changes.

[okular] [Bug 488497] Markdown not respecting linebreak

2024-06-17 Thread Albert Astals Cid
https://bugs.kde.org/show_bug.cgi?id=488497

Albert Astals Cid  changed:

   What|Removed |Added

   Severity|normal  |wishlist

-- 
You are receiving this mail because:
You are watching all bug changes.

[okular] [Bug 488497] Markdown not respecting linebreak

2024-06-17 Thread Sune Vuorela
https://bugs.kde.org/show_bug.cgi?id=488497

Sune Vuorela  changed:

   What|Removed |Added

 CC||k...@pusling.com

--- Comment #3 from Sune Vuorela  ---
(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.

-- 
You are receiving this mail because:
You are watching all bug changes.

[okular] [Bug 488497] Markdown not respecting linebreak

2024-06-17 Thread bugzilla_noreply
https://bugs.kde.org/show_bug.cgi?id=488497

machinedreamcatc...@temp752.ynh.fr changed:

   What|Removed |Added

 Ever confirmed|0   |1
 Resolution|NOT A BUG   |---
 Status|RESOLVED|REOPENED

--- Comment #2 from machinedreamcatc...@temp752.ynh.fr ---
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

-- 
You are receiving this mail because:
You are watching all bug changes.

[okular] [Bug 488497] Markdown not respecting linebreak

2024-06-16 Thread Albert Astals Cid
https://bugs.kde.org/show_bug.cgi?id=488497

Albert Astals Cid  changed:

   What|Removed |Added

 CC||aa...@kde.org
 Resolution|--- |NOT A BUG
 Status|REPORTED|RESOLVED

--- Comment #1 from Albert Astals Cid  ---
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.

-- 
You are receiving this mail because:
You are watching all bug changes.