Package: mdhtmlgen
Markdown based html generator.Generation requires: HTML template and markdown template.The generator has additional meta extensions that allow you to do metaprogramming in HTML.Installationpip install mdhtmlgenUsage$python-mmdhtmlgen--helpUsage: python -m mdhtmlgen [options]Options:-h, --help            show this help message and exit-S SOURCE, --source=SOURCEMarkdown source filename (*.md)-H HTML, --html=HTML  HTML template filename (*.t)-t, --trace           Print diagnostic traces-o OUTPUT, --output=OUTPUTSet output file-m MARKDOWN_EXT, --markdown-ext=MARKDOWN_EXTSet markdown extension list, coma separated, e.g.meta,toc,footnotes-d DATE_FMT, --date-fmt=DATE_FMTSet date format, e.g. %d-%m-%Y %H:%M:%S-e EXT, --ext=EXT     Set extension list, e.g. meta,glob,filename,date-a PARAMS, --add=PARAMSAdd parameter in format name:value-g GIT_DIR, --git-dir=GIT_DIRSet GIT directory location, e.g. /home/user/repo/.gitToolsWe usepythonas the template engine for html and markdown, and its ingenious feature isstring formatting using a dictionary.
A simple example:print('Dear%(name)s, I am interested in the%(post)sposition at your company…'%{'name':'Oliver','post':'Sales Manager'})Herenameandpostare template parameters. If you understand how this example works, then there will be no problems with the rest.Markdown itself does not generate html.
Markdown is responsible for the content, so we use an additional page template to generate the html.ExampleLet's create a simple page template -html.t:<!DOCTYPE html><html><head><title>%(title)s</title><metacharset="utf-8"/><linkrel="stylesheet"href="styles.css"/></head><body>%(body)s</body></html>Now let's add a content template for this page -example.md:---title: Example Page---## Task scenarioYou want to buy traveler’s checks with your credit card. Which percentage rate applies to the purchase?*Possible answers:**The Standard APR of 10.99%*The Cash Advance APR of 24.24%[^*]*The Penalty APR of 29.99%*I don’t know

[^*]:This is the correct answer, based on my own credit card company’s cardmember agreement.The last step is to combine 2 templates into 1 html:$python-mmdhtmlgen-Sexample.md-Hhtml.t-oexample.htmlThe same can be done via a redirect:$python-mmdhtmlgen-Sexample.md-Hhtml.t>example.htmlWhichever is more convenient - the result will be the same.As you can see, In HTML template was addedstyles.css. For our example, we can take ready styles,for example from the sindresorhus/github-markdown-css project, they cover themarkdownfunctionality.
But if it is not enough for you, you can always extendhtml.t, add links to additional styles and scripts.ExtensionsWithout extensions,markdownis very limited. A list of basic extensions can be foundon the markdown github page.
Intomdhtmlgen, you can pass a list of extensions to be used during generation using the-mor--markdown-extoption.Besides themarkdownextensions,mdhtmlgenhas its own meta extensions. At the moment there are 6 of them:filenameAdds path information to the template for the source:%(input-path)s- full source path%(input-name)s- name of source file%(input-ext)s- extension of source filename%(input-basename)s- basename of sourceand similar information about the output:%(output-path)s%(output-name)s%(output-ext)s%(output-basename)sstatAdds information about the file statistics of the source to the template:%(input-date-update)s- date and time when the file was last modified%(input-date-create)s- file creation date and time (if supported by FS)%(input-owner)s- file owner namegitAdds information about the statistics of a file in the Git repository to the template:%(input-date-commit)s- date and time when the file was last modified%(input-commiter)s- name of the last editor of the file%(input-date-add)s- date and time when the file was added to the repository%(input-author)s- the name of the first editor of the fileFor this extension, you need to specify the path to the repository using the--git-diroption (a similar option exists in Git, seeman git).customAllows you to add arbitrary meta-parameters to the template using the option-aor--addmetaImports a meta-parameter from another source into a template, example:%(input-file-date:other-example.md)s.Here we have extracted%(input-file-date)sfrom theother-example.mdsourceglobConcatenates meta parameters from different sources, example:%(glob:row:*.md)s.Here we have concatenated%(row)sfrom all sources using the search pattern*.md.Nativemdhtmlgenextensions can be enabled with the-eor--extoptions.