Is depth-agnostic heading syntax possible?

I think the problem with this discussion is that it sees Markdown as source code for HTML, rather as plain text content meant for consumption as-is (i.e. it is already its own rendering!).

If you see it as the latter as I do, also as it was originally envisioned[1], and also as CommonMark reaffirmed[2], then current headings work perfectly. If your content has no hierarchy, then use only level one headings. If you have headings that are nested, then use the appropriate sub-heading level. This works perfectly for humans reading the plain text as-is.

The linked HTML issue, that “using specific heading levels (<h4>) is it couples components to their containing context” is not relevant for Markdown as Markdown isn’t meant for constructing HTML pages with React components or any other HTML component.

Not unless by “component” you mean “a piece of text content that can get embedded within other content”. But even there, that’s the responsibility of the renderer that is doing the embedding. What I wrote about element IDs applies equally to heading levels:

It is the responsibility of the embedding context to respect and protect my scope. Whether in its rendering it avoids ID collisions by altering its IDs or mine, or demotes my heading levels to avoid multiple H1s, it is its business, its job to make it work.

There should be a clear separation of concerns between authoring content and publishing mechanics. I shouldn’t have to manage the technicalities of an output format while authoring in a format that is supposed to be independent and portable. As the content author, the only thing that matters is that I have a semantically unambiguous and intuitive way to create internal links. I don’t care how they are ultimately rendered.

…just change the last two sentences to “As the content author, the only thing that matters is that I have a semantically unambiguous and intuitive way to create hierarchical structure. I don’t care how they are ultimately rendered as long as that hierarchy is respected”.

@Crissov I think you get this:

But the syntax you describe for headingless sections goes back to treating Markdown as a source for HTML. I say that because the syntax you propose has the notion of hierarchy, but that won’t be evident to the human plain text reader, not unless they internalize your rules. The only natural ways for plain text to represent hierarchy are indentation, borders (e.g. block quote’s left border), or headings with heading levels. In other words, I don’t think your semantics for **** works, and the distinction between ---- and ____ doesn’t make sense for Markdown, which should only deal with semantic breaks, not presentation (e.g. horizontal rules).

See also What's a good way to go up one header / section? - #2 by vas


  1. The overriding design goal for Markdown’s formatting syntax is to make it as readable as possible. The idea is that a Markdown-formatted document should be publishable as-is, as plain text, without looking like it’s been marked up with tags or formatting instructions. Daring Fireball: Markdown ↩︎

  2. CommonMark spec: What is Markdown ↩︎