doesn't that make you wonder?

John MacFarlane jgm at berkeley.edu
Thu Oct 20 13:45:43 EDT 2011


+++ Fletcher T. Penney [Oct 20 11 13:22 ]:

>

> On Oct 20, 2011, at 12:52 PM, Tao Klerks wrote:

>

> > OK, I interpret this (besides the quite-reasonable "why should I care?" vibe), combined with previous references to the PEG grammar(s) implicit in MultiMarkdown and peg-markdown's implementations, as "a formal specification already exists".

>

> True. "A" formal spec exists, but there needs to be agreement when "THE" formal spec exists.

>

> I personally believe that peg-markdown is a fantastic start, and could easily become the standard after being vetted by various developers and users around the troublesome edge cases that are out there.

>

> Others may disagree with me, but I see little reason to reinvent the wheel when there is a really good wheel sitting in front of us that might just need some tweaking.


My more recent lpeg-based markdown implementation, lunamark, is better
than peg-markdown in many respects. It passes more of the tests
Michel Fortin made for PHP Markdown. It is also faster, and (I think)
the code is more readable, since lua is a more expressive language
than C.

https://github.com/jgm/lunamark/blob/master/lunamark/reader/markdown.lua

Sorry, I haven't kept track of the differences between the grammars
of peg-markdown and lunamark.

As for portability, well, nothing beats ANSI C, but lua comes close.
The lua interpreter is small is itself implemented in ANSI C, as is the
lpeg library. So lunamark could be made to run on anything that could
run peg-markdown.


> Yes - you have to have a definition of how you output the HTML. peg-markdown also does this through example, not through a formal specification. I'm not an expert on formal grammars, but I wonder if there is a single formal specification that will define the syntax and the output in a single document? Or will there need to be a different approach? In either case, this is also where the test suite will come into play.


It's better, in my opinion, to separate the parser and writer, as is
done in peg-markdown. The parser produces an abstract syntax tree
(AST), which the html and latex writers take as input.
The writers are very simple; the difficulties lie with the parsing
itself, and that's where a spec is really needed.
There could be a separate spec for canonical HTML output.

John


More information about the Markdown-Discuss mailing list