xmark = markdown + Tufte CSS

I have been using Markdown since, at least, 2004, when I started blogging.

I didn't know CommonMark until recently, though. And, well, it offers an XML backed Abstract Syntax Tree for your markdown documents. Now, I have to exploit that.

CommonMark

One of the major benefits of markdown markup is that it's easy for humans. You can learn Markdown in 60 seconds. It's easy to read and to write.

But it's not so easy for computers to understand. The CommonMark project is trying to define a common specification so that computers understand the same thing with a single Markdown document.

There are different CommonMark compliant Markdown processors out there (you can run one in your browser right now). One of my favourites is cmark, a plain C markdown processor that I can run on OS/X and FreeBSD, for instance.

The fact is that cmark is able to generate an XML representation of the markdown document. This is like an Abstract Syntax Tree for Markdown (see First steps towards an AST).

CommonMark AST + XSL

Now, an AST for Markdown documents is great. You can manipulate the AST in different ways to "compile" your document in the format you want. Since XML is the default output format of CommonMark's AST, the easiest way to compile it is through an XSLT stylesheet.

So I built one that compiles Markdown documents and compiles to Tufte-CSS powered HTML output.

It may generate a Table of Content for your markdown, supports HTML5 figures in the three Tufte-CSS formats (normal, full-width and margin figure), automatically generates figure and sidenote numbers, includes syntax highlighting and supports custom HTML in the Markdown document.

For more information:

Happy markdowning, Antonio