Formatting text in Markdown
Markdown is a very popular markup language used to create plain text that can be converted into styled HTML. It is a good way of structuring documents in a way that they are still easy to read in plain text format, while being able to properly style them in HTML.
In this recipe, we'll see how to transform a Markdown document into styled HTML using Python.
Getting ready
We should start by installing the mistune
module, which will compile Markdown documents into HTML:
$ echo "mistune==0.8.4" >> requirements.txt
$ pip install -r requirements.txt
In the GitHub repository, there is a template file called markdown_template.md
with a template of the report to generate.
How to do it...
- Import
mistune
anddatetime
:>>> import mistune >>> from datetime import datetime
- Read the template from the file:
>>> with open('markdown_template.md') as...