CDSoft / panda

Panda is a Pandoc Lua filter that works on internal Pandoc's AST. Panda is heavily inspired by [abp](http:/cdelord.fr/abp) reimplemented as a Pandoc Lua filter.
https://cdelord.fr/panda
GNU General Public License v3.0
43 stars 5 forks source link

current file as environmental variable #1

Closed kbro237 closed 3 years ago

kbro237 commented 3 years ago

Thanks for this project! I'm currently evaluating whether I can replace pp with panda or if I still need a preprocessor like upp.

Is there a way to access the name of the current file from panda? For example, with pp I used the macro !exec(date -r !file "+%Y-%m-%d") to set the metadata date to the date of the file's last modification.

CDSoft commented 3 years ago

Hi,

Panda does not know the current file since it works on the AST, not on the file. A workaround would be to set an environment variable before calling panda.

On the other side, pandoc provides a Lua table PANDOC_STATE which contains information about the input files. I can check if this table can be made available to panda.

CDSoft commented 3 years ago

I'm testing something in the branch input_and_output_files:

Thus we can write:

% test mdate
% someone
% `date -r {{input_file}} "+%Y-%m-%d"`{icmd=sh}
CDSoft commented 3 years ago

I've merged the branch input_and_output_files. I've also added similar variables to upp.