Parser question + Markdown "wysiwyg"

david parsons orc at pell.chi.il.us
Tue Apr 20 13:25:26 EDT 2010


In article <20100420094250339725.51497217 at yahoo.co.uk>,
Albert Skye <markdown-discuss at six.pairlist.net> wrote:

>http://eigenclass.org/R2/writings/fast-extensible-simplified-markdown-in-ocaml

>http://eigenclass.org/R2/writings/markdown-redux-html-generation


The ocaml markdown clone (it's explicitly not markdown by design, and
would take a little bit of editing to override the writer's intent) is
quite fast and small, but that's not really relevant to the original
question, is it?

In regards to the actual question, I do have code in discount that
creates a block-level parse tree, but I don't build a parse tree for
the content inside paragraphs. And I don't keep track of byte
offsets into the source. It wouldn't be difficult to add the
offset to the start of each paragraph into the data structures;
you'd need to keep track of byte & line offsets when lineilating the
input into the library, and then each paragraph object could easily
get to that information for its first line.

If you wanted to do the same for span-level markup, you'd be
completely on your own. I'm sorry about that, but I never
considered using discount as an interpreter instead of a compiler,
and it would probably take a fairly extensive redesign to get it
to work nicely without suffering a staggering performance penalty.

-david parsons


More information about the Markdown-Discuss mailing list