Skip to main content

Markdown parser that renders the markdown in HTML

Project description

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

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

Installation

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 setup.py install from the directory you extracted the files to

The Git way (No actual installation)

  1. Clone the GitHub repository

  2. Run python markdown-runner.py to use the tool

Usage

The usage is very easy. Once installed you can use tm-parse-markdown to access the program. Alternatively use python markdown-runner.py 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 -r, --renderer 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.

Example:

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

Example (with option):

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

Markdown Syntax

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

Headings

All headings from H1 to H6 are supported.

Examples:

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

Bold text

Bold text is supported.

Example:

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

Italic text

Italic text is supported.

Example:

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

Lists

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.

Example:

* 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*

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.

Example:

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*

0. a new list is started here

Quotes

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

Examples:

> This starts a one line quote.

> A new quote starts here
> and continues in the next line.
> It can contain **not rendered bold text** and *not rendered italic text*.

Paragraphs

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

Project details


Download files

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

Source Distribution

twomartens.markdown-1.0.0.dev3.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

twomartens.markdown-1.0.0.dev3-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file twomartens.markdown-1.0.0.dev3.tar.gz.

File metadata

File hashes

Hashes for twomartens.markdown-1.0.0.dev3.tar.gz
Algorithm Hash digest
SHA256 c475fac73dcf0dae53ac3ca461789b3e7f3c61fd12c63f55485b6624f157aa33
MD5 d59cf805112eaacb437bd5143409a6be
BLAKE2b-256 e16ae473b345a605464c14dfac40eb3ad0d6170d4f1233513db97ebebc3ce21f

See more details on using hashes here.

File details

Details for the file twomartens.markdown-1.0.0.dev3-py3-none-any.whl.

File metadata

File hashes

Hashes for twomartens.markdown-1.0.0.dev3-py3-none-any.whl
Algorithm Hash digest
SHA256 aa0d363f27974025d6a164a4a06a350558542be096251085ade0fff90cefeb3a
MD5 88c2e5e22d33f8eba9f81509c4cfd7d0
BLAKE2b-256 5aaa7abe42797b1d5bb1434709b8212e10cacc4a2fcc73838281a3ae76f9432f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page