aboutsummaryrefslogtreecommitdiff
path: root/pandoc
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2026-07-22 10:43:27 +0200
committerFlorian Fischer <florian.fischer@muhq.space>2026-07-22 10:43:27 +0200
commitcf996fa9ccae4a65ac4b79bd0131d5f0476bba9e (patch)
tree20d348a68ba2e55d01bce0743b4c4a22437faab5 /pandoc
parent439a7ed77fa6aff90854debfc0f765b2c1cc6e15 (diff)
downloadunterricht-cf996fa9ccae4a65ac4b79bd0131d5f0476bba9e.tar.gz
unterricht-cf996fa9ccae4a65ac4b79bd0131d5f0476bba9e.zip
pandoc: rewrite input paths in included files
Diffstat (limited to 'pandoc')
-rw-r--r--pandoc/filters/include-files.lua20
1 files changed, 20 insertions, 0 deletions
diff --git a/pandoc/filters/include-files.lua b/pandoc/filters/include-files.lua
index 06cfd4e6..a42ae1ec 100644
--- a/pandoc/filters/include-files.lua
+++ b/pandoc/filters/include-files.lua
@@ -41,6 +41,26 @@ local function update_contents(blocks, shift_by, include_path)
end
return image
end,
+ -- If tex input paths are relative then prepend include file path
+ RawBlock = function (el)
+ io.stderr:write("include-filter: Raw Block found.\n")
+ -- Only handle tex RawBlocks
+ if el.format ~= 'tex' then
+ return el
+ end
+ io.stderr:write("include-filter: Raw Tex Block found.\n")
+
+ el.text = el.text:gsub('\\input{([^}]+)}', function(match)
+ local input_path = match
+ if path.is_relative(include_path) then
+ include_path = path.normalize(path.join({include_path, input_path}))
+ end
+
+ return '\\input{' .. include_path .. '}'
+ end)
+
+ return el
+ end,
-- Update path for include-code-files.lua filter style CodeBlocks
CodeBlock = function (cb)
if cb.attributes.include and path.is_relative(cb.attributes.include) then