3

When rendering posts, a blockquote line followed by a blockquoted pseudo-setext heading underline ending with any character turns those lines into a setext heading.

Here's what the CommonMark spec section on setext headings says:

A setext heading consists of one or more lines of text, not interrupted by a blank line, of which the first line does not have more than 3 spaces of indentation, followed by a setext heading underline. The lines of text must be such that, were they not followed by the setext heading underline, they would be interpreted as a paragraph: they cannot be interpretable as a code fence, ATX heading, block quote, thematic break, list item, or HTML block.

A setext heading underline is a sequence of = characters or a sequence of - characters, with no more than 3 spaces of indentation and any number of trailing spaces or tabs. If a line containing a single - can be interpreted as an empty list items, it should be interpreted this way and not as a setext heading underline.

The heading is a level 1 heading if = characters are used in the setext heading underline, and a level 2 heading if - characters are used. The contents of the heading are the result of parsing the preceding lines of text as CommonMark inline content.

Note how in the section on the setext heading underline, trailing spaces and tabs are allowed, but that's it (not any other characters).

I'm not certain on the "any character" part, but I've tested with non-ASCII characters, so I think that says something.

Here's an example (a MRE of the original one I encountered in the wild (see revision 6)). The following markup:

> I'm a setext heading!?
> -1

Gets rendered as:

I'm a setext heading!?

I then went playing in the formatting sandbox. Feel free to constructively edit/add to my post there to do more experimentation.

Here's a list of other things that do reproduce:

> =2
> =a
> =⭐
> ==⭐

But the polar bear emoji (which is an example of an emoji composed of multiple characters joined by the Zero-Width-Joiner) does not produce this issue. Neither do other trailers that are composed of multiple ASCII-range characters:

> =ab
> =abc123
> ==🐻‍❄️

The other weird thing is that these don't get rendered as headings in the editor render preview. For example the first example I showed gets rendered in the editor render preview as if the markup were written as > I'm a setext heading!? -1.

0

1 Answer 1

1

I'm assuming that this alternate markup syntax for section headings is loosely based on reStructuredText

Stack Exchange uses CommonMark not reStructuredText (reST). Both derive from the earlier Setext and reST predates Markdown which evolved into CommonMark. Functionally the Markdown spec is a subset of reST.

blockquote line of reStructuredText title markup

> I'm a title!?
> -1

That is not title markup! In reST you can have section titles while in CommonMark you can have ATX headings or setext headings.

Since each language has its own specification you have to get the nomenclature exactly right when mentioning a construct otherwise there's no way to know what you mean.


What's happening in the difference between the first example and the other two seems like a peculiarity of SE's CommonMark implementation because the second example doesn't render as separate paragraphs in the CommonMark sandbox there's nothing in the spec to indicate the - or the = don't make for paragraph continutation text used with that indentation and those leading characters.

2
  • 1
    Thanks! I've attempted to update my question to use more correct wording. Can you please peer-review my updated question and correct anything that needs correcting and improve anything that you think needs improving? Please also update your answer accordingly. Sorry for the trouble.
    – starball
    Commented Dec 22, 2022 at 8:52
  • @starball that's really the thing, technically the answer to the question stays the same. I think the 1st example is correct and the other two are likely bugs. I'll leave the initial part of my answer as is for the benefit of the readers.
    – bad_coder
    Commented Dec 22, 2022 at 8:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .