jgm / djot

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

{_ opener can match with bare _ #119

Closed matklad closed 1 year ago

matklad commented 1 year ago
{_ x_ _}

This is somewhat counter-intuitively parsed as <em> x</em> _}, not as <em> x_ </em>

jgm commented 1 year ago

This is actually according to spec.

In cases of ambiguity, { and } may be used to mark delimiters as openers or closers. Thus {_ behaves like _ but can only open emphasis, while _} behaves like _ but can only close emphasis:

Nothing here says that {_ must pair with _}; it can be closed by any _ which can close emphasis.

I agree, though, that visually you'd expect something else here.

I'd have to think about what would be required to add the rule that an explicit {x marker can only be closed by an explicit x}.