CommonMark Formal Grammar

@gagern I’d love to have a formal grammar; I just don’t know how to do it.

A while back I wrote a couple of PEG grammars for Markdown:
peg-markdown (in C) and lunamark (in lua).

I had to work around various rough edges (the backtick code spans were one of them, and I think I just supported up through 5 backticks). I’m not happy with either of these efforts.

I’m not familiar with some of the more esoteric grammars you mention in your post, so if you want to investigate this, it would be welcome. I think it’s possible to use the Pumping Lemma to prove that the grammar for backtick code spans is not context-free.

1 Like