jgm/djot

section nesting for non-consecutive heading levels

Opened this issue · 1 comments

From https://djot.net/playground/

If you have:

### Heading 3
## Heading 2
#### Heading 4

then the AST is

doc
  section
    heading level=3
      str text="Heading 3"
  section
    heading level=2
      str text="Heading 2"
    section
      heading level=4
        str text="Heading 4"

This maybe does not really make sense and could be problematic for a post-processor / writer

would it make sense to do something like generate "phantom" sections, e.g.

doc
  section phantom
    section phantom
	  section
	    heading level=3
	      str text="Heading 3"
	  section
	    heading level=2
	      str text="Heading 2"
		section phantom
		    section
		      heading level=4
		        str text="Heading 4"
jgm commented

I've found from pandoc that people have very different expectations about this. Some people really want to be able to have nested sections with heading levels that skip. So I'm tempted to say: if you don't want this, don't write the djot headings this way.

It's also possible to write a filter that traverses the AST and "fixes" heading levels, or even inserts phantom sections.

But we can keep this open to see what others think about this issue. It would certainly be possible to insert a phantom section in this way.