This is an extension to Python-Markdown which allows conditional compilations to be inserted into the text.
This module can now be installed using pip.
$ pip install md-condition
The syntax for use within your Markdown files is
<!--- #if DEBUG -->
# md-condition DEBUG
<!--- #else -->
not DEBUG
<!--- #endif -->
<!--- #if RELEASE -->
# md-condition RELEASE
<!--- #else -->
not RELEASE
<!--- #endif --><h1>md-condition DEBUG</h1>
<p>not RELEASE</p>symboldefines one or more symbols:DEBUG,DEBUG RELEASE,DEBUG|RELEASE, or a list[DEBUG, RELEASE]. With nosymbolconfigured, every#ifis false.<!--- #if A B -->is true when any defined symbol is exactly one of the listed names (DEBUGdoes not matchDEBUG_X). Names are separated by spaces and/or|, so#if A | Band#if A|Bmean the same.#elseis optional; nested#ifblocks are not supported.- Malformed blocks (unclosed
#if, stray#else/#endif, duplicate#else, nesting) raisemd_condition.ConditionSyntaxErrorwith the offending line number and text. - Inside fenced code blocks (
```/~~~), complete#if…#endifblocks still apply (conditional code samples), but malformed directives are left as text, so docs can show md-condition syntax without breaking the build.
In your mkdocs.yml add this to markdown_extensions.
markdown_extensions:
- md_condition:
symbol: DEBUGTo define several symbols at once:
markdown_extensions:
- md_condition:
symbol: [DEBUG, RELEASE]