Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

section nesting for non-consecutive heading levels #294

Open
chrisjsewell opened this issue Apr 5, 2024 · 1 comment
Open

section nesting for non-consecutive heading levels #294

chrisjsewell opened this issue Apr 5, 2024 · 1 comment

Comments

@chrisjsewell
Copy link

chrisjsewell commented Apr 5, 2024

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
Copy link
Owner

jgm commented Apr 5, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants