aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2026-10-04 15:41:41 +0200
committerFlorian Fischer <florian.fischer@muhq.space>2026-10-04 15:41:41 +0200
commitfd1475aaec33e717a3721679008bc42bb96d0998 (patch)
tree6036f0b86e0aa5bdd1837c861749ef3bf6e1d395
parentd3a3ad033eca9229b9df1cea6f4595b78b7b462b (diff)
downloadunterricht-fd1475aaec33e717a3721679008bc42bb96d0998.tar.gz
unterricht-fd1475aaec33e717a3721679008bc42bb96d0998.zip
pandoc allow markdown in LaTex environments
TODO: pass arguments to the LaTeX environments
-rw-r--r--common.mk1
-rw-r--r--pandoc/filters/div-class-to-env.lua31
-rw-r--r--templates/slides.md10
3 files changed, 37 insertions, 5 deletions
diff --git a/common.mk b/common.mk
index 8726a163..f4ad4ebe 100644
--- a/common.mk
+++ b/common.mk
@@ -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}