For fenced blocks, consider requiring exact match on the number of delimiters
matklad opened this issue · 2 comments
Current spec says:
A div begins with a line of three or more consecutive colons, optionally followed by white space and a class name (but nothing else). It ends with a line of consecutive colons at least as long as the opening fence,
This creates somewhat unintuitive results:
::: block
What would be the difference here?
:::: details
Trick question, they are equivalent.
::::
Hey, I am outside of both divs!
:::
(the example extracted from a real-world bug in my blog)
An extra considiration is that you might start with just a single div. But, if you later decide to add extra content inside, the current rule requires you to update the outer div as well, which is a non-local modification.
Also, ####
is nested under ###
, it'd be weired if for divs its the opposite, and :::
is nested under ::::
Yes, this is a good point...I guess, being familiar with this from pandoc, I always use the longer fence for the outer one.
Here's the original motivation for allowing longer closing fences (for both code and divs): it can look nice visually to balance the part of the opening line that has attributes with a longer line on the bottom.
::: {#note .important}
This is a note.
:::::::::::::::::::::::
Pandoc also supports this form, which is very nice visually:
::::::: warning :::::::
This is a warning.
:::::::::::::::::::::::
This consideration is weaker for djot, because in djot, you put the attributes above the div fence, and the second form isn't allowed (though maybe it should be).
A second argument is that if we allow fenced code to be closed by longer strings of backticks, it's consistent to do the same for fenced divs.
Neither of these arguments is super-strong, I'm just explaining the reasoning.