guile-user
[Top][All Lists]
Advanced

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

Re: [ANN] guile-commonmark 0.1 (A markdown parser)


From: Thompson, David
Subject: Re: [ANN] guile-commonmark 0.1 (A markdown parser)
Date: Mon, 25 Jul 2016 09:44:55 -0400

On Sun, Jul 24, 2016 at 10:33 PM, Erik Edrosa <address@hidden> wrote:
>
> As a bonus for haunt users, here is an example using guile-commonmark as
> a reader to generate a blog written in markdown.
>
>     (use-modules (haunt asset)
>                  (haunt builder blog)
>                  (haunt builder atom)
>                  (haunt reader)
>                  (haunt site)
>                  (haunt post)
>                  (commonmark))
>
>     (define commonmark-reader
>       (make-reader (make-file-extension-matcher "md")
>                    (lambda (file)
>                      (call-with-input-file file
>                        (lambda (port)
>                          (values (read-metadata-headers port)
>                                  (commonmark->sxml port)))))))
>
>     (site #:title "Built with Guile"
>           #:domain "example.com"
>           #:default-metadata
>           '((author . "Eva Luator")
>             (email  . "address@hidden"))
>           #:readers (list commonmark-reader)
>           #:builders (list (blog)
>                            (atom-feed)
>                            (atom-feeds-by-tag)))
>
> Now just save the above as haunt.scm and put your markdown blog posts in
> the posts directory with a .md extension and run `haunt build`. Here is
> an example blog post:
>
>     title: Hello World!
>     date: 2016-07-24 10:00
>     tags: guile, commonmark, scheme
>     ---
>
>     A CommonMark Document
>     ===============
>     Here is some *scheme* `code`
>     ```scheme
>     (display "Hello, World!")
>     ```
>
>     1. A list
>     2. Another item in a list
>
>     Read more about [CommonMark](http://commonmark.org/)
>
>
> Please note the header on top portion of the post which allows you to
> add metadata to your blog posts for haunt.

This is just wonderful! Thank you!

If you have the time/motivation, I would love to see a patch to Haunt
itself that adds guile-commonmark as an optional dependency.  There's
prior art for this because guile-reader is also optional, so it would
mostly be a copy/paste job in configure.ac and Makefile.am to
conditionally include the markdown reader module in the list of source
modules.

- Dave



reply via email to

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