unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* [potluck dish] A CommonMark parser
@ 2016-02-16 22:36 Erik Edrosa
  2016-02-18  1:49 ` Thompson, David
  0 siblings, 1 reply; 2+ messages in thread
From: Erik Edrosa @ 2016-02-16 22:36 UTC (permalink / raw
  To: guile-user

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/



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [potluck dish] A CommonMark parser
  2016-02-16 22:36 [potluck dish] A CommonMark parser Erik Edrosa
@ 2016-02-18  1:49 ` Thompson, David
  0 siblings, 0 replies; 2+ messages in thread
From: Thompson, David @ 2016-02-18  1:49 UTC (permalink / raw
  To: Erik Edrosa; +Cc: Guile User

Hello Erik,

On Tue, Feb 16, 2016 at 5:36 PM, Erik Edrosa <erik.edrosa@gmail.com> wrote:
> 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.

Thanks for this tasty dish!  The code looks great and I'm happy to see
it that parses to SXML.  I hope you are able to make an official
release some time.  I would love to add support for this to my static
site generator.

Happy hacking!

- Dave



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-02-18  1:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-16 22:36 [potluck dish] A CommonMark parser Erik Edrosa
2016-02-18  1:49 ` Thompson, David

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