marker
marker is an OTP library for parsing and rendering Markdown documents.
Currently it supports a most elements of the CommonMark specification
listed here. See root README.md for details.
The goal is to support full CommonMark specification and then add add support for the other ones, e.g. Github Flavored Markdown.
Build
To build the library just run make. The default target build the library
and runs unit tests as you can read below:
$ make help
build Builds library source with rebar3
default Builds the sources and run unit tests.
test Runs Eunit tests for all modules.API
marker library consists of two modules and each of them exports one function:
markerwhich handles parsing of Markdown documents and exports:markdown/1function accepting a string with Markdown document and returning its tree representation
renderwhich handles HTML rendering and exports:html/1function accepting the tree returned bymarkdown/1and returning the string with HTML code, ready to display.
Tree structure
The tree returned by the markdown/1 function has a regular recursive structure
with text elements as leaves. Each element may be in either this form for
non-leaves:
{<type_atom>, [<child_element>,...]}or this - leaves:
{<type_atom>, <text>}
The <type_atom> above can be one of these:
document- the root of the tree
Non-leaves, block elements:
horizontal_line- rendered as<hr>block_quote- rendered as<blockquote>bullet_list- rendered as<ul>list_item- rendered as<li>paragraph- rendered as<p>soft_break- rendred as<br>heading<1-6>- rendered as<h<1-6>>code_fence- rendered as<pre>, code block
Leaves:
inline_code- rendered as<code>italic- rendered as<i>emph- rendered as<b>str- rendered as regular text