Skip to main content

Markdown parser that transforms the markdown into HTML

Project description

This program was created in the context of the code competition of in April 2017. It is split into two main components. The parser side takes the Markdown input and creates an internal representation. The transform component uses the internal representation and creates the HTML output.

In general the system is designed to be modular and expandable. For example a transformation for LaTeX could be relatively easily added.


Easy way

Use the package manager of Python:

pip install twomartens.markdown

A bit more complicated

  1. Download the package from the PyPi
  2. Extract the files
  3. Run python install from the directory you extracted the files to

The Git way (No actual installation)

  1. Clone the GitHub repository
  2. Run python to use the tool


The usage is very easy. Once installed you can use tm-parse-markdown to access the program. Alternatively use python instead if you followed the Git way. The rest applies to both forms in the same way. The program accepts two parameters. The first needs to be the name of a file containing Markdown code. The second parameter has to be the name of the output file. The file doesn’t have to exist already but if it does it will be overwritten completely. The output file will contain the markup in the selected output format (as of now it is always HTML).

To allow for easier extension the program accepts the -f, --format option. It can be used to specify the output format. Currently only HTML is supported which is also selected by default. Therefore it is not required to specify the option for the program to work.


tm-parse-markdown my-html-file.html

Example (with option):

tm-parse-markdown --format html my-html-file.html

Markdown Syntax

The markdown parser supports the following syntax. More might be added later.


All headings from H1 to H6 are supported.


# H1 heading
## H2 heading
### H3 heading
#### H4 heading
##### H5 heading
###### H6 heading

Bold text

Bold text is supported.


**bold text**
the **bold text** can even appear in normal paragraphs

Italic text

Italic text is supported.


*some italic text*
the *italic text* can also appear in paragraphs

Inline code

Inline code segments are supported.


a paragraph with `inline code`


Both unordered and ordered lists are supported. The list items for unordered lists have to start their line with *, - or + immediately followed by a space. These symbols can be used interchangeably even within one list. An empty line must precede a list.


* this starts a list
* which continues here
* and here
- even here
+ and here

* but this is a new list
* which even contains **bold text** and *italic text*
* or an `inline code segment`
* or a [link](, <>

The list items of ordered lists have to start with numbers (0-9), followed by a dot (.) and a space. It doesn’t matter for the output which numbers stand in front of the dot.


1.  this starts an ordered list
2.  which is continued here
9.  and here
0.  it can also contain **bold text**
11. and *italic text*
99. and `inline code`
42. and a [link]( "title"), <>

0. a new list is started here


As of now only block quotes are supported. Inline quotes might be added later.


> This starts a one line quote.

> A new quote starts here
> and continues in the next line.
> It can contain **bold text** and *italic text*.
> inline `code blocks` are also possible
> The same goes for [links](, <>

Code blocks

Code blocks are supported. They have to be preceded and followed by an empty line. Each line must start with either 4 spaces or one tab. The text is encoded so that you can easily use for example HTML tags in a code block. Further spaces beyond these four spaces or one tab are represented in the output unchanged.


<!DOCTYPE html>


Paragraphs are naturally supported as well. They are separated from each other with empty lines.


A paragraph starts here. It contains **bold text** or *italic text*.
It continues in the next line with a `code segment`.
Finally there are also [links]( "title")

This text belongs to a new paragraph.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for twomartens.markdown, version 1.0.0a1
Filename, size File type Python version Upload date Hashes
Filename, size twomartens.markdown-1.0.0a1-py3-none-any.whl (15.4 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size twomartens.markdown-1.0.0a1.tar.gz (11.6 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page