Markmin markup language


This is a new markup language that we call markmin designed to produce high quality scientific papers and books and also put them online. We provide serializers for html, latex and pdf. It is implemented in the markmin2html function in the

Example of usage:

>>> m = "Hello **world** [[link]]"
>>> from markmin2html import markmin2html
>>> print markmin2html(m)
>>> from markmin2latex import markmin2latex
>>> print markmin2latex(m)
>>> from markmin2pdf import markmin2pdf # requires pdflatex
>>> print markmin2pdf(m)


We wanted a markup language with the following requirements:

(results depend on text but in average for text ~100K markmin is 30% faster than markdown, for text ~10K it is 10x faster)

The web2py book published by lulu, for example, was entirely generated with markmin2pdf from the online web2py wiki

Download and are single files and have no web2py dependence. Their license is BSD.


Bold, italic, code and links

# title title
## section section
### subsection subsection
**bold** bold
''italic'' italic
``verbatim`` verbatim
[[click me #myanchor]]click me

More on links

The format is always [[title link]]. Notice you can nest bold, italic and code inside the link title.


You can place an anchor anywhere in the text using the syntax [[name]] where name is the name of the anchor. You can then link the anchor with link, i.e. [[link #myanchor]].


some image This paragraph has an image aligned to the right with a width of 200px. Its is placed using the code

[[some image right 200px]].

Unordered Lists

- Dog
- Cat
- Mouse

is rendered as

Two new lines between items break the list in two lists.

Ordered Lists

+ Dog
+ Cat
+ Mouse

is rendered as

  1. Dog
  2. Cat
  3. Mouse


Something like this

**A** | **B** | **C**
0 | 0 | X
0 | X | 0
X | 0 | 0
is a table and is rendered as
Four or more dashes delimit the table and | separates the columns. The :abc at the end sets the class for the table and it is optional.


A table with a single cell is rendered as a blockquote:

Hello world

Code, <code>, escaping and extra stuff

def test():
    return "this is Python code"

Optionally a ` inside a ``...`` block can be inserted escaped with !`!. The :python after the markup is also optional. If present, by default, it is used to set the class of the <code> block. The behavior can be overridden by passing an argument extra to the render function. For example:

>>> markmin2html("``aaa``:custom",
       extra=dict(custom=lambda text: 'x'+text+'x'))



(the ``...``:custom block is rendered by the custom=lambda function passed to render).

Html5 support

Markmin also supports the <video> and <audio> html5 tags using the notation:

[[title link video]]
[[title link audio]]

Latex and other extensions

Formulas can be embedded into HTML with $$formula$$. You can use Google charts to render the formula:

>>> LATEX = '<img src="" align="center"/>'
>>> markmin2html(text,{'latex':lambda code: LATEX % code.replace('"','"')})

Code with syntax highlighting

This requires a syntax highlighting tool, such as the web2py CODE helper.

>>> extra={'code_cpp':lambda text: CODE(text,language='cpp').xml(),
           'code_java':lambda text: CODE(text,language='java').xml(),
           'code_python':lambda text: CODE(text,language='python').xml(),
           'code_html':lambda text: CODE(text,language='html').xml()}
>>> markmin2html(text,extra=extra)

Code can now be marked up as in this example:


Citations and References

Citations are treated as internal links in html and proper citations in latex if there is a final section called "References". Items like

- [[key]] value

in the References will be translated into Latex

\bibitem{key} value

Here is an example of usage:

As shown in Ref.``mdipierro``:cite

## References
- [[mdipierro]] web2py Manual, 3rd Edition,


<ul/>, <ol/>, <code/>, <table/>, <blockquote/>, <h1/>, ..., <h6/> do not have <p>...</p> around them.