On Sun, Jul 24, 2016 at 10:33 PM, Erik Edrosa <[email protected]> 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 . "[email protected]")) > #: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
