diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2026-10-04 15:41:41 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2026-10-04 15:41:41 +0200 |
| commit | fd1475aaec33e717a3721679008bc42bb96d0998 (patch) | |
| tree | 6036f0b86e0aa5bdd1837c861749ef3bf6e1d395 | |
| parent | d3a3ad033eca9229b9df1cea6f4595b78b7b462b (diff) | |
| download | unterricht-fd1475aaec33e717a3721679008bc42bb96d0998.tar.gz unterricht-fd1475aaec33e717a3721679008bc42bb96d0998.zip | |
pandoc allow markdown in LaTex environments
TODO: pass arguments to the LaTeX environments
| -rw-r--r-- | common.mk | 1 | ||||
| -rw-r--r-- | pandoc/filters/div-class-to-env.lua | 31 | ||||
| -rw-r--r-- | templates/slides.md | 10 |
3 files changed, 37 insertions, 5 deletions
@@ -17,6 +17,7 @@ PANDOC_CITE_OPTIONS := --citeproc PANDOC_FILTER_OPTIONS := --lua-filter "$(PANDOC_FILTER_DIR)/include-files.lua" PANDOC_FILTER_OPTIONS += --lua-filter "$(PANDOC_FILTER_DIR)/center-img.lua" PANDOC_FILTER_OPTIONS += --lua-filter "$(PANDOC_FILTER_DIR)/meta-vars.lua" +PANDOC_FILTER_OPTIONS += --lua-filter "$(PANDOC_FILTER_DIR)/div-class-to-env.lua" PANDOC_FILTER_OPTIONS += --filter pandoc-plot -M plot-configuration=$(PANDOC_DIR)/defaults/pandoc-plot.yml COMMON_PANDOC_OPTIONS := --data-dir="$(PANDOC_DIR)" --resource-path="$(COMMON_IMAGES):." $(PANDOC_FILTER_OPTIONS) PANDOC_XARGS ?= diff --git a/pandoc/filters/div-class-to-env.lua b/pandoc/filters/div-class-to-env.lua new file mode 100644 index 00000000..1a87777b --- /dev/null +++ b/pandoc/filters/div-class-to-env.lua @@ -0,0 +1,31 @@ +--- div-class-to-env.lua – filter to convert classes to LaTeX environments +--- +--- Copyright: © 2026 Florian Fischer +--- License: MIT – see LICENSE file for details + +if FORMAT:match('beamer') then + function Div(d) + -- ignore code blocks which are not of class "env". + if not d.classes:includes 'env' then + return + end + + local env + for _, v in ipairs(d.classes) do + if v ~= 'env' then + env = v + break + end + end + + if not env then + return + end + + return { + pandoc.RawInline('latex', '\\begin{'..env..'}'), + d, + pandoc.RawInline('latex', '\\end{'..env..'}') + } + end +end diff --git a/templates/slides.md b/templates/slides.md index 4c7e30c7..c03104c6 100644 --- a/templates/slides.md +++ b/templates/slides.md @@ -83,9 +83,9 @@ class AKTE { ## Some Text in custom tcolorboxes -`\begin{merke}`{=latex} -Der Grundsatz der \beamerpgap{2}{\boldred{Datenkapselung}} besagt, dass nur ein Objekt selbst Zugriff auf seine Attribute haben sollte. -`\end{merke}`{=latex} +:::{.env .merke} +Der Grundsatz der \beamerpgap{2}{\boldred{Datenkapselung}} besagt, dass nur ein **Objekt** selbst Zugriff auf seine *Attribute* haben sollte. +::: \pause\pause @@ -95,13 +95,13 @@ Der Zugriff von außen sollte nur über durch das Objekt bereitgestellte Methode \pause -`\begin{pseudocode}`{=latex} - +:::{.env .pseudocode} ``` Solange du willst... Mache was. Mache was anderes. ``` +::: `\end{pseudocode}`{=latex} |
