summaryrefslogtreecommitdiff
path: root/_extensions/js/multicol-nohead/multicol-nohead.lua
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2025-05-31 14:54:58 +0200
committerJonas Smedegaard <dr@jones.dk>2025-06-07 08:55:45 +0200
commitd32faa12679eb29b122f63fbf541cd2b47169e0e (patch)
treeda842d80f2a2c7ecd876f0145ced35dc7db1fffe /_extensions/js/multicol-nohead/multicol-nohead.lua
parent89e81dc251c27bfd546a6409a9071b2116f41657 (diff)
add and use new filter extension multicol
Diffstat (limited to '_extensions/js/multicol-nohead/multicol-nohead.lua')
-rw-r--r--_extensions/js/multicol-nohead/multicol-nohead.lua47
1 files changed, 47 insertions, 0 deletions
diff --git a/_extensions/js/multicol-nohead/multicol-nohead.lua b/_extensions/js/multicol-nohead/multicol-nohead.lua
new file mode 100644
index 0000000..1fa5d4a
--- /dev/null
+++ b/_extensions/js/multicol-nohead/multicol-nohead.lua
@@ -0,0 +1,47 @@
+-- Render content below header in three columns
+
+local multicol_begin = pandoc.RawBlock('latex', [[
+\begin{multicols}{2}\raggedcolumns
+]])
+local multicol_end = pandoc.RawBlock('latex', [[
+\end{multicols}
+]])
+
+local multicol_now = false
+
+-- TODO: include header level 2 and author paragraph above multicolumn
+function is_author(elem)
+ return elem.t == Para and elem.content[1].text == "Forfatter:"
+end
+
+function multicol_delimit(elem)
+ if multicol_now == true then
+ return {multicol_end, elem, multicol_begin}
+ else
+ multicol_now = true
+ return {elem, multicol_begin}
+ end
+end
+
+function Header(elem)
+ if FORMAT:match 'latex' then
+ if elem.level == 1 then
+ return multicol_delimit(elem)
+ end
+ end
+end
+
+function HorizontalRule(elem)
+ if FORMAT:match 'latex' then
+ return multicol_delimit(elem)
+ end
+end
+
+function Pandoc(doc)
+ if FORMAT:match 'latex' then
+ if multicol_now == true then
+ doc.blocks:insert(multicol_end)
+ return doc
+ end
+ end
+end