From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Erik Edrosa Newsgroups: gmane.lisp.guile.user Subject: [ANN] guile-commonmark 0.1 (A markdown parser) Date: Sun, 24 Jul 2016 22:33:45 -0400 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------755689AD3BCA4B2BD37F37BA" X-Trace: ger.gmane.org 1469414064 5415 80.91.229.3 (25 Jul 2016 02:34:24 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 25 Jul 2016 02:34:24 +0000 (UTC) To: "guile-user@gnu.org" Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Mon Jul 25 04:34:19 2016 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1bRVih-0001Gx-Kr for guile-user@m.gmane.org; Mon, 25 Jul 2016 04:34:15 +0200 Original-Received: from localhost ([::1]:58289 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bRVig-0001sp-PU for guile-user@m.gmane.org; Sun, 24 Jul 2016 22:34:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34565) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bRViJ-0001sZ-1g for guile-user@gnu.org; Sun, 24 Jul 2016 22:33:52 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bRViG-0003AT-MZ for guile-user@gnu.org; Sun, 24 Jul 2016 22:33:49 -0400 Original-Received: from mail-oi0-x244.google.com ([2607:f8b0:4003:c06::244]:33221) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bRViG-00039n-Fv for guile-user@gnu.org; Sun, 24 Jul 2016 22:33:48 -0400 Original-Received: by mail-oi0-x244.google.com with SMTP id l9so15484406oih.0 for ; Sun, 24 Jul 2016 19:33:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=to:from:subject:message-id:date:user-agent:mime-version; bh=z5KyIb77JFUGeM8tbJ4H9n6ywuGp1cjV/QMqt1aCb5E=; b=x6o42BWY2qSFMJ5s7SxWH6+ywk/a3HilRmMDqbzP54wtkwu298yMzBOS2pXqUFcybg 5IAO0DUGhOJ6IWj6WQy+qQT7kMD2gmuju0YadJO1qUJhX8Kgq8ZRlUsJgztFjsJBamyV +19G432H1zpEJ8hAJ00sshwT3yD784I+84wCxNzuKjc40yVcoe+EdUqqBHb2N3BEN+dR A5b4WG+fk50hwu/5TKXD6YogFxF/8aJgxZLoUnE4j8jLup4UH+805FOc//7dD4r86nH7 IiPeAw/8nSXwCvhGju2vnkiEZFaxTOpSCSRFN124zalWUFXq+07mg6oif4MNMdjMC4jJ 6zHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version; bh=z5KyIb77JFUGeM8tbJ4H9n6ywuGp1cjV/QMqt1aCb5E=; b=OOFQuZALCLq69yx7E9x1v6EKdYd2UIv37nE3mw/M8J7ym9p+DDXnMXYHHmxFmagDdc hZdWnYnCpo/9eZr8vtH7XtGl8lgxQho0vu6QmBlgHxqGpM7DyGGB73sz6ev1n/BewM2f F7Ldkfaufh218pdFHxEkjTs/WcKcXJ+QD36n660D4tFCVYOvWebHTDtFy3pfdnOigeQq lzGkobYuGzU6qCch4l0eAWEHVdsl3L6HEQkneH3aYi2Nt55FJ9WLcOBZtOVpdqhxMZ5m Zf7s7G1JwNdipoqe6sBYCgz8ArI0Ai0vciDrWnWCQ287UGnngO88ajmqcO2uzftb6ZDL yMVQ== X-Gm-Message-State: AEkooutAop0EfO4bX04A+SpPtxbizT/SmAlZzyDOwg12nteqh2lgjlYVyyVMZXFWih3bkg== X-Received: by 10.157.29.66 with SMTP id m60mr8814055otm.113.1469414027375; Sun, 24 Jul 2016 19:33:47 -0700 (PDT) Original-Received: from ?IPv6:2602:306:c5c9:a3e0:be5f:f4ff:fe45:6041? ([2602:306:c5c9:a3e0:be5f:f4ff:fe45:6041]) by smtp.googlemail.com with ESMTPSA id u107sm10383706ota.31.2016.07.24.19.33.46 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Jul 2016 19:33:46 -0700 (PDT) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:4003:c06::244 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.org gmane.lisp.guile.user:12790 Archived-At: This is a multi-part message in MIME format. --------------755689AD3BCA4B2BD37F37BA Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit 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):

A CommonMark Document

Here is some scheme code

      (display "Hello, World!")
      
    
  1. A list
  2. Another item in a list

Read more about CommonMark

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/ --------------755689AD3BCA4B2BD37F37BA Content-Type: text/x-scheme; name="guix.scm" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="guix.scm" (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=20 (string-append "https://github.com/OrangeShark/guile-commonmark/re= leases/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 specifi= ed variant of Markdown.") (home-page "https://github.com/OrangeShark/guile-commonmark") (license lgpl3+)) --------------755689AD3BCA4B2BD37F37BA--