Spec
tcr — 2014-09-04T14:29:09-04:00 — #1
An existing concern with the current STMD spec is that it defines many plain-english examples of Markdown parsing but does not contain a formal grammar. It's been suggested that a state machine like that found in the HTML5 spec would be more appropriate.
Vanilla-flavored Markdown, licensed as MIT and whose author has commented on STMD [1], contains a fully-defined specification [2] in the form of a state machine parser that may be exactly what implementors are looking for aside from grammar examples.
This project has not yet been brought up on the forums, so I thought I would suggest the idea of collaboration in a new topic. I'm not affiliated with the project.
[1] https://news.ycombinator.com/item?id=8267039
[2] http://www.vfmd.org/vfmd-spec/specification/
maradydd — 2014-09-04T15:37:27-04:00 — #2
Don't get me wrong, I love state machines, but holy crap those regexps make me want to put my eyes out.
Has anyone even tried writing a context-free-grammar version of a markdown spec? I'm starting to get the impression that the answer is no.
riking — 2014-09-04T16:26:14-04:00 — #3
I'm guessing that the answer is "Yes, they failed."
Markdown is not context-free, it has several constructs that are clearly context-sensitive, then you have lists which introduce recursion, and hello! You have arrived at level 0 of the Chomsky hierarchy.
maradydd — 2014-09-04T16:33:59-04:00 — #4
Fine, then a context-sensitive formalism it is. But even context-free grammars can recurse on existing elements, including in lists; it is no problem at all, for instance, to have rules like
foo ::= bar* baz qux
bar ::= '[' foo ']'
That form of recursion is what distinguishes the context-free languages from the regular languages.
I'm working on an ABNF spec (per RFC 5234) in my Copious Free Time and am aiming to have that done by the weekend.
jc404 — 2014-09-04T18:59:58-04:00 — #5
(post withdrawn by author, will be automatically deleted in 24 hours unless flagged)