unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Erik Edrosa <erik.edrosa@gmail.com>
To: guile-user@gnu.org
Subject: [potluck dish] A CommonMark parser
Date: Tue, 16 Feb 2016 17:36:09 -0500	[thread overview]
Message-ID: <56C3A459.2070006@gmail.com> (raw)

Hello,

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
inline.

The code can be found at https://github.com/OrangeShark/guile-commonmark

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

(define doc
  "A CommonMark Document
===============
Here is some scheme code
```scheme
(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)
(newline)


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


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.

Thanks
Erik - OrangeShark


[0]: http://commonmark.org/
[1]: http://daringfireball.net/projects/markdown/



             reply	other threads:[~2016-02-16 22:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-16 22:36 Erik Edrosa [this message]
2016-02-18  1:49 ` [potluck dish] A CommonMark parser Thompson, David

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56C3A459.2070006@gmail.com \
    --to=erik.edrosa@gmail.com \
    --cc=guile-user@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).