-
Notifications
You must be signed in to change notification settings - Fork 0
adoc admonitions.py
Pandoc filter that processes asciidoc-style admonitions and encloses them in a DIV with a specified class. These admonitions consist of a single line/paragraph message written in a simple manner and rendered according to a user configuration.
The admonitions words appearing in the first column of a paragraph followed by a colon (:) and a space. For example:
NOTE: this is a note
These are invalid:
NOTE:this (no space after the colon)
NOTE: this (not in the first column)
The default admonition names/classes are coded in the LINKS dictionary. The keys represent the admonition text (without the : ) and the value represents the class (HTML)/environment (LaTeX/beamer) that the paragraph will be enclosed into.
ADMONITIONS = { "NOTE": "note", "TIP": "tip", "ERROR": "error", "CODE": "term", "WARNING": "warn", "QUOTE": "quote" }
This can be overridden or expanded using a metadata block, at the top of your Markdown file, with the name adoc-admonition:
---
adoc-admonition:
xxx: admonitionnote
TIP: TIPADMONITION
...
With that in place, the changes will be:
xxx: xxx is a new admonition enclosed in a admonitionnote Div
TIP: overrides the default class and sets the new one as TIPADMONITION
In the specific case of Latex/Beamer output the admonitions are output inside an environment like:
NOTE: the note
\begin{note}
the note.
\end{note}
-
Install python 3 (version >3.9) and pandoc
-
Install panflute python libraries
pip3 install panflute
-
Download and place the file in directory:
~/.pandoc/filters
pandoc -s test.md -t beamer --filter adoc-admonitions.py
Prof. Georgios Pappas Jr
University of Brasilia (UnB) - Brazil