lua-filters icon indicating copy to clipboard operation
lua-filters copied to clipboard

Add running additional filters in `include-files.lua`

Open gabyx opened this issue 5 years ago • 2 comments

I wanted to make PR to add functionality to run additional filter after the recursive transclusion.

-- recursive transclusion
contents = pandoc.walk_block(
  pandoc.Div(contents),
  { Header = update_last_level, CodeBlock = transclude }
  ).content

-- apply all filters if any
if filters then
  for i,f in ipairs(filters) do
    doc = pandoc.Pandoc(contents, metadata)
    contents = utils.run_json_filter(doc, "pandoc").blocks
  end
end

But I got stuck since it needs a more general run_filter function to run all sort of filters: See https://github.com/jgm/pandoc/issues/6830.

Can this be done, or is there another approach around.

Application: I want some filters to be run which affect the transclusion of include-files.lua. Namely replacing variables inside the include blocks

```{.include filter="codeblock-var-replace"}
${meta:chapterPath}/A.md
```

gabyx avatar Nov 11 '20 23:11 gabyx

Here a potential workaround.

I'm using a 2 steps generation.

  1. I run pandoc to create one complete md file
  2. I use this file as source for normal generation with all my plugins

ghost avatar Jan 15 '21 13:01 ghost

pandoc 3.1.2 solves this problem perfectly!

wenbopeng avatar Apr 11 '23 14:04 wenbopeng