Use Markdown extensions in Nikola
| Anke (encarsia)
Inhalt
The default markup language of input files in Nikola is restructuredText. You can, of course, configure Nikola to also process Markdown formatted files but by default there are missing some features like admonitions or table of contents which can be enabled by extensions.
Basic configuration
First things first: you have to edit the variables COMPILERS
, POSTS
and PAGES
of the conf.py and uncomment or add a line in order to make Nikola recognize and render Markdown files:
COMPILERS = { "rest": ('.rst', '.txt'), "markdown": ('.md', '.mdown', '.markdown'), ... } POSTS = ( ("posts/*.rst", "posts", "post.tmpl"), ... ("posts/*.md", "posts", "post.tmpl"), ) PAGES = ( ("pages/*.rst", "pages", "story.tmpl"), ... ("pages/*.md", "pages", "story.tmpl"), )
Markdown extensions
There are two types of Markdown extensions:
Officially supported extensions that are shipped with the python-markdown package.
Third party extensions which have to be installed separately on your system.
Enable
An extension is enabled by adding it to the MARKDOWN_EXTENSIONS
variable.
If you want to enable officially supported extensions you add the extensions' entry point as list item. If the extension is part of the extra folder you can use extra
as list item or the name of the extension, p.e. you enable definition lists with either def_list
or extra
.
The list item for a third party extension is the exact dot notation (see the extension's documentation).
Examples
MARKDOWN_EXTENSIONS = [# all extensions of extra available "extra", # other officially supported extensions "admonition", "toc", # third party extension "markdown_include.include", ]
Configure
Some extensions offer configuration options. These are defined in the MARKDOWN_EXTENSIONS_CONFIGS
variable. The dictionary's structure is
MARKDOWN_EXTENSIONS_CONFIGS = { DEFAULT_LANG: { "ext1": {"option1": value1, "option2": value2", }, "ext2": {"option1": value1, "option2": value2", }, ... }, "other_configured_lang": { "ext1": {"option1": value1, "option2": value3", }, ... }, }
Use
Consult the extension's documentation for details. Useful extensions:
Comments
Comments powered by Disqus