unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* [ANN] guile-commonmark 0.1 (A markdown parser)
@ 2016-07-25  2:33 Erik Edrosa
  2016-07-25 13:44 ` Thompson, David
  2016-08-04 16:59 ` Christopher Allan Webber
  0 siblings, 2 replies; 4+ messages in thread
From: Erik Edrosa @ 2016-07-25  2:33 UTC (permalink / raw)
  To: guile-user@gnu.org

[-- Attachment #1: Type: text/plain, Size: 3532 bytes --]

Hello everyone,

Awhile back for the potluck I posted a CommonMark[0] parser I written in
pure Guile Scheme which outputs SXML. Today I have decided to release
version 0.1, it currently supports parsing almost the entire CommonMark
spec besides block and inline HTML. guile-commonmark will not support
block and inline HTML as the spec allows malformed HTML to be written
which can't be transformed to SXML. guile-commonmark also follows a
slightly older version of the spec and one of the major differences are
tabs are expanded into spaces(including tabs in code blocks).

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 in a list

    Read more about [CommonMark](http://commonmark.org/)")

    ;; 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 <em>scheme</em> <code>code</code></p>
    <pre>
      <code class="language-scheme">(display &quot;Hello, World!&quot;)
      </code>
    </pre>
    <ol>
      <li>A list</li>
      <li>Another item in a list</li>
    </ol>
    <p>Read more about <a href="http://commonmark.org/">CommonMark</a></p>


You may download the release at
https://github.com/OrangeShark/guile-commonmark/releases/download/v0.1/guile-commonmark-0.1.tar.gz

GNU Guix users can install guile-commonmark using the attached guix.scm file

guile-commonmark is still a young project, so expect plenty of bugs.
Please report any bugs to https://github.com/OrangeShark/guile-commonmark


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  . "eva@example.com"))
          #: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.

Thanks,
Erik

[0]: http://commonmark.org/

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: guix.scm --]
[-- Type: text/x-scheme; name="guix.scm", Size: 872 bytes --]

(use-modules (guix packages)
             (guix licenses)
             (guix build-system gnu)
             (guix download)
             (gnu packages guile))

(package
  (name "guile-commonmark")
  (version "0.1")
  (source
   (origin
     (method url-fetch)
     (uri 
       (string-append "https://github.com/OrangeShark/guile-commonmark/releases/download/v"
                      version "/guile-commonmark-" version ".tar.gz"))
     (sha256
      (base32
        "12cb5fqvvgc87f5xp0ih5az305wnjia89l5jba83d0r2p8bfy0b0"))))
  (build-system gnu-build-system)
  (inputs
   `(("guile" ,guile-2.0)))
  (synopsis "CommonMark parser for GNU Guile")
  (description
   "guile-commonmark is a library for parsing CommonMark, a fully specified
variant of Markdown.")
  (home-page "https://github.com/OrangeShark/guile-commonmark")
  (license lgpl3+))

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

* Re: [ANN] guile-commonmark 0.1 (A markdown parser)
  2016-07-25  2:33 [ANN] guile-commonmark 0.1 (A markdown parser) Erik Edrosa
@ 2016-07-25 13:44 ` Thompson, David
  2016-07-26  0:58   ` Erik Edrosa
  2016-08-04 16:59 ` Christopher Allan Webber
  1 sibling, 1 reply; 4+ messages in thread
From: Thompson, David @ 2016-07-25 13:44 UTC (permalink / raw)
  To: Erik Edrosa; +Cc: guile-user@gnu.org

On Sun, Jul 24, 2016 at 10:33 PM, Erik Edrosa <erik.edrosa@gmail.com> 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  . "eva@example.com"))
>           #: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



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

* Re: [ANN] guile-commonmark 0.1 (A markdown parser)
  2016-07-25 13:44 ` Thompson, David
@ 2016-07-26  0:58   ` Erik Edrosa
  0 siblings, 0 replies; 4+ messages in thread
From: Erik Edrosa @ 2016-07-26  0:58 UTC (permalink / raw)
  To: Thompson, David; +Cc: guile-user@gnu.org

On 07/25/2016 09:44 AM, Thompson, David wrote:
> On Sun, Jul 24, 2016 at 10:33 PM, Erik Edrosa <erik.edrosa@gmail.com> 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  . "eva@example.com"))
>>           #: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
> 

Definitely, I have been playing around with haunt and managed to switch
my current blog to use haunt and guile-commonmark. I have a couple of
ideas to add to haunt, so I will hopefully be sending you some patches soon.

Thanks,
Erik



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

* Re: [ANN] guile-commonmark 0.1 (A markdown parser)
  2016-07-25  2:33 [ANN] guile-commonmark 0.1 (A markdown parser) Erik Edrosa
  2016-07-25 13:44 ` Thompson, David
@ 2016-08-04 16:59 ` Christopher Allan Webber
  1 sibling, 0 replies; 4+ messages in thread
From: Christopher Allan Webber @ 2016-08-04 16:59 UTC (permalink / raw)
  To: Erik Edrosa; +Cc: guile-user@gnu.org

Erik Edrosa writes:

> Hello everyone,
>
> Awhile back for the potluck I posted a CommonMark[0] parser I written in
> pure Guile Scheme which outputs SXML. Today I have decided to release
> version 0.1, it currently supports parsing almost the entire CommonMark
> spec besides block and inline HTML. guile-commonmark will not support
> block and inline HTML as the spec allows malformed HTML to be written
> which can't be transformed to SXML. guile-commonmark also follows a
> slightly older version of the spec and one of the major differences are
> tabs are expanded into spaces(including tabs in code blocks).
>
> 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 in a list
>
>     Read more about [CommonMark](http://commonmark.org/)")
>
>     ;; 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 <em>scheme</em> <code>code</code></p>
>     <pre>
>       <code class="language-scheme">(display &quot;Hello, World!&quot;)
>       </code>
>     </pre>
>     <ol>
>       <li>A list</li>
>       <li>Another item in a list</li>
>     </ol>
>     <p>Read more about <a href="http://commonmark.org/">CommonMark</a></p>
>
>
> You may download the release at
> https://github.com/OrangeShark/guile-commonmark/releases/download/v0.1/guile-commonmark-0.1.tar.gz
>
> GNU Guix users can install guile-commonmark using the attached guix.scm file
>
> guile-commonmark is still a young project, so expect plenty of bugs.
> Please report any bugs to https://github.com/OrangeShark/guile-commonmark
>
>
> 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  . "eva@example.com"))
>           #: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.
>
> Thanks,
> Erik
>
> [0]: http://commonmark.org/

This is awesome!  We should get this packaged for Guix :)

Nice work!



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

end of thread, other threads:[~2016-08-04 16:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-25  2:33 [ANN] guile-commonmark 0.1 (A markdown parser) Erik Edrosa
2016-07-25 13:44 ` Thompson, David
2016-07-26  0:58   ` Erik Edrosa
2016-08-04 16:59 ` Christopher Allan Webber

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