Skip to content
tristanjuricek edited this page Sep 13, 2010 · 3 revisions

Another Markdown Knockoff…

This time, with an object model!

But tell me, why do you want such a thing?

Because you want to mess with your Markdown output, that’s why! Say you want to HTML-ify your markdown document. Why not use the first header of the Markdown as the <title> of the <head>?

How to grab the first header of your markdown document.

Or default it to do something.

val blocks = KnockOff.parse( markdownSource ).get

val header = blocks.find( _.isInstanceOf[ Header ] ) match {
    case header:Header => SpanConverter( header.nads ).toString
    case None => "My Default Header"
}

Note that the object model and the “conversion” process is pretty alpha at this point. I haven’t used it much yet. That whole SpanConverter thing will get pimped at some point, probably to header.nads.text.