[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[potluck dish] A CommonMark parser

From: Erik Edrosa
Subject: [potluck dish] A CommonMark parser
Date: Tue, 16 Feb 2016 17:36:09 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1


I've been working on a parser for CommonMark[0], a specified version of
Markdown[1] being worked on (still not 1.0). It currently does not parse
the full spec, but it works so far for all block structures except for
HTML blocks. The code is still pretty rough and I welcome any feedback
to improve it. I am following their suggested strategy of parsing
CommonMark in two steps by parsing the block level structure and then

The code can be found at

Here is an example usage:
(use-modules (commonmark)
             (sxml simple))

(define doc
  "A CommonMark Document
Here is some scheme code
(display \"Hello, World!\")

1. A list
2. Another item")

;; Parse the CommonMark document into sxml
(define doc-sxml (commonmark->sxml doc))

;; Writes to current output port
(sxml->xml doc-sxml)

which outputs(formatted for readability):
<h1>A CommonMark Document</h1>
<p>Here is some scheme code</p>
  <code class="language-scheme">
(display &quot;Hello, World!&quot;)
    <p>A list</p>
    <p>Another item</p>

I plan to have the 0.1 release cover both blocks and inlines and as much
of the current spec as possible. This will include parsing HTML in
CommonMark documents, but I am unsure if whether the default behavior
should be unsafe (does not escape any HTML) with a safe flag or the
opposite. Any suggestions to improve is appreciated.

Erik - OrangeShark


reply via email to

[Prev in Thread] Current Thread [Next in Thread]