mexdown is a a lightweight markup language that is easily extensible. Here are some of its properties:
--This is struckthrough. **This is both.-- This is bolded.**
, and produce the following--This is struckthrough. **This is both.**--** This is bolded.**
Perhaps the most important feature of mexdown is the directive. A directive consists of n >= 3
consecutive backticks and an executable command. Its body follows directly after, terminated by another sequence of n
backticks. Here is an example used to include a latex equation into a document.
```svglatex --inline $\cos (2\theta) = \cos^2 \theta - \sin^2 \theta$ ```
In this example, the body is an inline latex equation that is sent verbatim into svglatex, a small utility command I wrote that converts a latex document into SVG using dvisvgm. The output of svglatex then replaces everything between the triple-backquotes. Here is the result after compilation:
The parser is completely decoupled from the backend document generators. A major flaw in many lightweight markup languages is that they narrowly target a specific language for code generation, like HTML. mexdown aims to be language-agnostic in its construction, so the parser is oblivious to the subsequent phases of compilation. It's sole job is to produce a syntax tree representation of the document. Details like html escaping and overlapping markup are treated in the backend, and don't pollute the parser. Although I currently only have an html backend, my plan is to create a Google Slides backend to automatically generate a presentation.
Although mexdown works on the command line with various options and configurations, it can equivalently be used as a Go library. This is particularly useful for server-side document-generation.
ast := parser.MustParse(reader) gnr := html.Gen(ast) gnr.Stdout = os.Stdout if err := gnr.Run(); err != nil { log.Fatal(err) }
I hope you will use this library and welcome your contributions. Please file issues at github.com/smasher164/mexdown.