diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2026-07-22 10:43:27 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2026-07-22 10:43:27 +0200 |
| commit | cf996fa9ccae4a65ac4b79bd0131d5f0476bba9e (patch) | |
| tree | 20d348a68ba2e55d01bce0743b4c4a22437faab5 | |
| parent | 439a7ed77fa6aff90854debfc0f765b2c1cc6e15 (diff) | |
| download | unterricht-cf996fa9ccae4a65ac4b79bd0131d5f0476bba9e.tar.gz unterricht-cf996fa9ccae4a65ac4b79bd0131d5f0476bba9e.zip | |
pandoc: rewrite input paths in included files
| -rw-r--r-- | pandoc/filters/include-files.lua | 20 |
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 |
