Skip to content

Improve pandoc lua filters handling to make it more usable from other package #1897

@cderv

Description

@cderv

We are currently adding some lua filter also in rstudio/bookdown#940

There are several pieces missing to make things easier to extend what is done in rmarkdown

  1. pandoc_lua_filters helper is currently only working for rmarkdown filter. We currently create the same helper for each 📦

  2. The lua filters are not including the same way in all 📦 so it is not easy to make another package filter run before or after another one.

About 2, sometime it is add inside the pre_processor part of the function

# a lua filters added if pandoc2.0
args <- c(args, pandoc_lua_filters(c("pagebreak.lua", "latex-div.lua")))

and in others outside of the pre preprocessor in the main format function, before pandoc_args argument

rmarkdown/R/pdf_document.R

Lines 145 to 149 in 284b685

# lua filters (added if pandoc > 2)
args <- c(args, pandoc_lua_filters(c("pagebreak.lua", "latex-div.lua")))
# args args
args <- c(args, pandoc_args)

We could start fixing this by being more aligned in all format.

And to improve, I think we need a mechanism for choosing the order of the filter (pandoc will run in the order of the command line). This is necessary to avoir conflicts. There are several ways to that IMO - one is to make lua filters activate with a switch.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions