Build Modules
Build modules are high-level bundles of settings, with various built-in ones available via lamarkdown.m.<modulename>()
; e.g.:
import lamarkdown as la
la.m.plots() # Invoke the m.plots build module
Here are the standard build modules:
Build Module | Description |
---|---|
m.doc() |
Styles output as a professional-looking document, and invokes various extensions. Acts as the set of defaults when no build files exist. |
m.plots() |
Adds support for several text-based graphics tools. |
m.code() |
Adds styling for syntax-highlighted code, as produced by Pygments. |
m.page_numbers() |
Adds pseudo-page numbers to the output document. |
m.teaching() |
Adds styling relevant to an educational environment, for tests or other assessments. |
You can create your own build module as a standard Python module. Within the module, place all Lamarkdown API calls inside a function, and invoke a function from your build file:
# my_build_mod.py (custom build module)
from lamarkdown import la
def apply():
la.css('p { background: black; color: white; }')
# md_build.py (build file)
import my_build_mod
my_build_mod.apply() # Invoke your custom build module
Design Notes
The function can be called anything. It is required, though, because putting Lamarkdown API calls into the top-level scope of your custom build module won’t work reliably, especially in live update (-l
/--live
) mode. Code in this scope only runs once, when the module is first loaded, whereas we want it to run whenever the document is recompiled.
By contrast, build files (e.g., md_build.py
) do have code in their top-level scope, because they are loaded/re-loaded via a customised mechanism, not a standard import
statement.