Rethinking possible syntax harmonization while documenting existing extensions, I had an idea for a systematic approach regarding the Hierarchy section in my initial post from three years ago, which is a problem only dealt with in the initial post in the thread @chrisalley linked to.
Consideration
Markdown and Commonmark do not use the concept of empty paragraphs, empty headings or empty emphasized spans, but as part of a mental model they make some sense.
An underlined heading consists of the underline and one or more lines before it that would otherwise be parsed as a paragraph. If this paragraph is empty, the underline is considered a thematic break instead. This line of thinking works only for ---
and longer uninterrupted lines of hyphens right now. It becomes either a relative and generic empty heading or an absolute second-level empty heading.
The empty emphases in foo ____ bar
and foo **** bar
are rendered as their verbatim markers, but if they are the sole content of a paragraph they become indistinguishable from thematic breaks. In vanilla Commonmark, the only difference between underscore _
and asterisk *
emphasis is in intra-word markup, but if we consider a sensible extension that aligns asterisks with more semantic (HTML) markup <em>
and <strong>
, and underscores with more presentational markup <i>
/<u>
and <b>
, then a line of asterisks associates more with an explicit section break </section><section>
and a line of underscores sounds more like a traditional horizontal rule <hr>
.
Conclusion (= TL;DR)
-
----
: empty headingsection
break – continue in new anonymous sibling section -
****
: structuralsection
break – continue in parent section afterwards -
____
: visualhr
break
# Foo # Foo # Foo
Bar Bar Bar
## Baz ## Baz ## Baz
---- **** ____
Quuz Quuz Quuz
.
<section> <section> <section>
<h1>Foo</h1> <h1>Foo</h1> <h1>Foo</h1>
<p>Bar</p> <p>Bar</p> <p>Bar</p>
<section> <section> <section>
<h2>Baz</h2> <h2>Baz</h2> <h2>Baz</h2>
</section> </section>
<section> <hr/>
<p>Quuz</p> <p>Quuz</p> <p>Quuz</p>
</section> </section>
</section> </section> </section>
Related Topic
Fenced Flowerbox headings, especially at the second level, can reuse thematic breaks.
# Parent ## Sibling ### Nephew
--------- --------- ---------
Flowerbox Flowerbox Flowerbox
--------- --------- ---------
This falls back gracefully if the parser disposes all empty sections after it has finished parsing the document.
Explicit Section Breaks
First pass:
<section>
<section> <section> <section>
<h1>Parent</h1> <h2>Sibling</h2> <h3>Nephew</h3>
</section><section> </section><section> </section><section>
<section> </section><section> </section>
</section><section>
<h2>Flowerbox</h2> <h2>Flowerbox</h2> <h2>Flowerbox</h2>
</section> </section> </section>
</section>
Final pass:
<section>
<section> <section> <section>
<h1>Parent</h1> <h2>Sibling</h2> <h3>Nephew</h3>
</section><section> </section> </section>
<section> <section> </section><section>
<h2>Flowerbox</h2> <h2>Flowerbox</h2> <h2>Flowerbox</h2>
</section> </section> </section>
</section>
Implicit Section Breaks
If only headings are used to generate sections.
<section>
<section> <section> <section>
<h1>Parent</h1> <h2>Sibling</h2> <h3>Nephew</h3>
<hr/> <hr/> <hr/>
</section> </section>
<section> <section> </section><section>
<h2>Flowerbox</h2> <h2>Flowerbox</h2> <h2>Flowerbox</h2>
</section> </section> </section>
</section>
Vanilla Commonmark
<h1>Parent</h1> <h2>Sibling</h2> <h3>Nephew</h3>
<hr/> <hr/> <hr/>
<h2>Flowerbox</h2> <h2>Flowerbox</h2> <h2>Flowerbox</h2>