laurent22 / joplin

Joplin - the privacy-focused note taking app with sync capabilities for Windows, macOS, Linux, Android and iOS.
https://joplinapp.org
Other
45.84k stars 4.97k forks source link

Markdown immediately following HTML isn't rendered correctly #10879

Closed urbite closed 1 month ago

urbite commented 2 months ago

Operating system

Windows

Joplin version

Joplin 2.14.23

Desktop version info

Joplin 2.14.23 (prod, win32)

Client ID: cc3d6d3080164b5cbb264b01fa4efaef Sync Version: 3 Profile Version: 46 Keychain Supported: Yes

Revision: 7b6a19a

Backup: 1.4.0

Current behaviour

When HTML is immediately followed by markdown, the markdown is not rendered correctly. More specifically, the markdown is rendered as unformatted text. 'Immediately followed by' means on the next line, e.g. there is no blank line between the HTML and markdown code.

In this specific case, an HTML table is immediately followed by a heading tag. Here's a screen cap from Joplin, with subject area highlighted. It's interesting to note that the markdown is rendered correctly in the markdown editor but not in the final output!?

image

Simply adding a blank line between the end of the HTML and the markdown fixes the issue.

image

Expected behaviour

The expectation is that Joplin would correctly render the markdown following html code, even without a blank line separating the two. As a simple test I pasted the complete HTML table and markdown as posted above into the Typora app and it rendered correctly.

Typora source

image

Typora rendered

image

This can be reproduced by the following simple code block, with a blank html table

<table>
</table>
### Final repair
In all likelihood, the freezer light with the mondo LED will last long after 

Logs

No response

personalizedrefrigerator commented 2 months ago

The upstream markdown-it editor shows the same behavior.

urbite commented 2 months ago

I'm not familiar with markdown-it. Is this a component in Joplin?

It is interesting that the same behavior is observed. Is there something in the markdown spec about what can or can't follow html?

Regarding the lack of a blank line between the end of the html table the markdown, this occurs in two places in one of my pages. I had a look at that page in OneNote and in both cases there is no line between the table and the heading.

Not stated previously in this issue, but I used OneNote Md Exporter to covert my OneNote notebook. Apparently the converter is correctly passing on the line spacing (or lack thereof) in the notebook.

personalizedrefrigerator commented 2 months ago

I'm not familiar with markdown-it. Is this a component in Joplin?

markdown-it is a JavaScript library for rendering Markdown to HTML. Joplin renders Markdown with an extended version of the markdown-it library.

This issue on markdown-it's GitHub repository may be relevant.

Edit: This seems to be the relevant part of the CommonMark spec:

[...]

  1. Start condition: line begins with the string < or </ followed by one of the strings (case-insensitive) address, article, aside, base, basefont, blockquote, body, caption, center, col, colgroup, dd, details, dialog, dir, div, dl, dt, fieldset, figcaption, figure, footer, form, frame, frameset, h1, h2, h3, h4, h5, h6, head, header, hr, html, iframe, legend, li, link, main, menu, menuitem, nav, noframes, ol, optgroup, option, p, param, search, section, summary, table, tbody, td, tfoot, th, thead, title, tr, track, ul, followed by a space, a tab, the end of the line, the string >, or the string />. End condition: line is followed by a blank line.

[...]

HTML blocks continue until they are closed by their appropriate end condition, or the last line of the document or other container block. This means any HTML within an HTML block that might otherwise be recognised as a start condition will be ignored by the parser and passed through as-is, without changing the parser’s state.

https://spec.commonmark.org/0.31.2/#html-blocks

github-actions[bot] commented 1 month ago

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? If you require support or are requesting an enhancement or feature then please create a topic on the Joplin forum. This issue may be closed if no further activity occurs. You may comment on the issue and I will leave it open. Thank you for your contributions.

github-actions[bot] commented 1 month ago

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, feel free to create a new issue with up-to-date information.