jgm / djot

A light markup language
https://djot.net
MIT License
1.66k stars 43 forks source link

# in heading generates more headings #91

Closed hellux closed 1 year ago

hellux commented 1 year ago

The syntax reference states that a heading is a sequence of # characters followed by whitespace followed by inline content. So I would expect

# # a

to result in a heading "# a" but instead it results in 2 headings "" and "a".

+heading 1-1
-heading 1-1
+heading 3-3
str 5-5
-heading 5-5

Also for multi-line headings, the reference states that they end with a blank line or an enclosed container, so I would expect

# a
# b

to result in a single heading "a # b" but instead it results in two headings:

+heading 1-1
str 3-3
-heading 3-3
+heading 5-5
str 7-7
-heading 7-7
jgm commented 1 year ago

Yeah - that's weird and not intended! Will need to look into it.

jgm commented 1 year ago

On your second question, multiline headings would look like this:

# This is a
multi-line heading

Here is the paragraph.

Or you could indent:

# This is a
  multi-line heading
hellux commented 1 year ago

Actually, I was wondering if it was intended to allow a heading on the line immediately after another heading. From the wording in the syntax reference, it sounds like there must be a blank line between two headings, otherwise it will become a single multiline heading.

jgm commented 1 year ago

It was intended to allow this, but I agree it's not clear from the syntax doc.

I'm open to persuasion though about this. Maybe it would be better to make

# a
# b

a multiline heading with content a b?

jgm commented 1 year ago

Reopening since at least I think we want to rewrite the syntax doc.

hellux commented 1 year ago

It was intended to allow this, but I agree it's not clear from the syntax doc.

I'm open to persuasion though about this. Maybe it would be better to make

# a
# b

a multiline heading with content a b?

Yeah, this seems more useful to me, and also quite intuitive.

More generally, I think I prefer requiring a blank line after any block for simpler parsing / syntax description and better readability.

kmaasrud commented 1 year ago

Maybe it would be better to make

# a
# b

a multiline heading with content a b?

+1 on this.