Search code examples
luapandoc

use lua filter for pandoc - what is correct path?


I have a lua filter (from question). The code for the filter is in file combine.lua in the same directory as the files to process with

pandoc --from=combine.lua index.md 0*.md -o res1.pdf

Now I want to apply the same filter to files with corresponding names in another directory and assumed I could just use a fully qualified filepath to the lua filter as

pandoc --from=/home/frank/Workspace11/experiments_SSG_related/booklet/combine.lua  index.md 0*.md -o res1.pdf

but I get the error

Error running Lua:
cannot open /home/frank/workspace11/experiments_ssg_related/booklet/combine.lua: No such file or directory

I have no experience with Lua, but notice that the file path returned has changed my uppercase inputs in lowercase.

What is the best procedure to call a lua filter when applying it to files in different directories? Where to store the filter? how to call it?


Solution

  • This turned out to be a bug in pandoc; I've fixed it, and the next release (pandoc 3.2) should no longer have that problem.

    For the moment my suggestion would be to place the custom writer in the custom folder of pandoc's data directory: we can run pandoc -v to find the directory that pandoc checks for data files; a Lua script placed in custom/combine.lua can be used by writing just --from combine.lua.

    On my system pandoc -v yields

    pandoc 3.1.1
    Features: +server +lua
    Scripting engine: Lua 5.4
    User data directory: /home/albert/.local/share/pandoc
    Copyright (C) 2006-2023 John MacFarlane. Web:  https://pandoc.org
    This is free software; see the source for copying conditions. There is no
    warranty, not even for merchantability or fitness for a particular purpose.
    

    so I'd have to place the file in /home/albert/.local/share/pandoc/custom/combine.lua.

    Note, however, that this require pandoc 3.0 or later; pandoc 2.19 supported this as well, but searched the readers folder instead of custom.