mirror of
https://github.com/xoofx/markdig.git
synced 2026-02-03 21:36:36 +00:00
Horizontal rule triggers Heading 2 #365
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @rpc-scandinavia on GitHub (May 17, 2020).
When converting MarkDown to HTML.
This:
Becomes:
Instead of:
Finally this works:
I understand that with the H1 and H2 with = and -, the = or - should be the same length as the heading, like this:
I do not know whether or not the last one, should be a heading 2 or a horizontal rule. Both have alternatives like ## and ***.
@MihaZupan commented on GitHub (May 17, 2020):
This behavior is as defined in the CommonMark spec, see Example 29.
See comparison between different parsers.
The solution is to add blank lines if you use
---, or to use a different character for the thematic break (_or*).or
turns into
It can be of any length as per example 53.
@rpc-scandinavia commented on GitHub (May 17, 2020):
On this page they show that --- is a horizontal rule:
https://commonmark.org/help/
@rpc-scandinavia commented on GitHub (May 17, 2020):
And:
Written on this GitHub page.
@MihaZupan commented on GitHub (May 17, 2020):
See example 29 I linked above, it explains exactly this case.
And even in the example they add that extra blank line
@MihaZupan commented on GitHub (May 17, 2020):
I agree with that statement 100%
@rpc-scandinavia commented on GitHub (May 17, 2020):
Example 29 shows that:
Should become H2, but NOT:
Only when the upper line is 3 characters long.
@xoofx commented on GitHub (May 17, 2020):
See babelmark for how it behaves
As @MihaZupan said, it is per the spec. All CommonMark implementations are following that.
@rpc-scandinavia commented on GitHub (May 17, 2020):
Example 53 is the opposite of what their HELP page shows, it says that "---" and "***" is a horizontal rule. It also shows that the headers use the same length for the text and the "-"s or "="s.
@xoofx commented on GitHub (May 17, 2020):
It's not invalid. You are focusing on a corner case. If you want a
---to be interpreted as an horizontal line, it would require a separating blank line before the preceding paragraph.CommonMark/Markdown is full of corner cases, that's why there is a CommonMark spec for that.
@MihaZupan commented on GitHub (May 17, 2020):
It's an example reference table to demonstrate language features. It can't include all specific corner cases of the language - that's why a specification document exists, and it is the spec that is the source of truth as to how parsers should behave.
That is how it's usually written because it looks better in monospaced font - that does not mean it's required.
@rpc-scandinavia commented on GitHub (May 17, 2020):
I understand all that when I read the spec, that there are corner cases and behaviour decisions has been made - but the help page was the first place I looked when trying to test my program, and I expect that is what users do too.
@rpc-scandinavia commented on GitHub (May 17, 2020):
Anyway, I just thought there was an error.
Thank you for the great software.
@xoofx commented on GitHub (May 17, 2020):
Yeah, it's not really their fault. A help page is not supposed to start to enter corner cases.
And frankly, Markdown is full of that, that's why sometimes users are confused and also why it's so difficult to get a parser right.