Can you change the date with a filter? #9345
DescriptionIs it possible to run a filter that will be able to run before Quarto processes I'm looking at a simple filter that looks like this: function Meta(el)
quarto.log.output(el["date"])
endWhen run on a blank document with Inlines {
[1] Str {
clone: function: 0x7fbf52893980
text: "May"
walk: function: 0x7fbf52893d90
}
[2] Space {
clone: function: 0x7fbf52895320
walk: function: 0x7fbf52895710
}
[3] Str {
clone: function: 0x7fbf528969d0
text: "5,"
walk: function: 0x7fbf52894fa0
}
[4] Space {
clone: function: 0x7fbf528981e0
walk: function: 0x7fbf528985e0
}
[5] Str {
clone: function: 0x7fbf528998e0
text: "2024"
walk: function: 0x7fbf52899ce0
}
}So the filter is running after Quarto has processed the date field. I get the same output regardless of when I run the filter at The upshot, as far as I can tell, is that something like this isn't possible: function Meta(el)
el["date"] = "1/1/24"
endOr rather, it is possible, but this change of date happens after the date formatter has run, so it will just display as "1/1/24" in the doc instead of "January 1, 2024". Is there any way to get such a filter to run before the date formatter or to re-run the date formatter? Thanks! |
Replies: 1 comment 9 replies
|
As you found date is processed in Quarto processing before Pandoc runs lua. So this won't be possible. Can you say more about what you want to do exactly ? How you would need to change date ? for what purpose ? With more information on the why, we can help more on the how. thanks ! |
I see. thanks
There are some metadata you won't be able to modify from a Lua filter. You would need to pass them differently - like using shared metadata file or passing metadata at command line rendering.
For this specific
dateusage, won't the date of included the same as the rendering as you schedule your document ?special cases
today,noworlast-modifieddoes not help ?Unfortunately, I am thinking only of workarounds this limitation, not real solution. Another one that comes to mind is a pre-render script that modify the date in the YAML of the document.
Though I wonder if variables could be used with the
datefields (https://quarto.org/docs/authoring/variables.html#var) - they are…