How to call one lua filter from another lua filter in a different file #13039
-
DescriptionI have one lua filter function ftsize(el)
if FORMAT:match 'latex' then
contents = el.content
table.insert(contents, 1, pandoc.RawInline('latex', '{\\raggedright {\\footnotesize '))
table.insert(contents, pandoc.RawInline('latex', '}}'))
end
return contents
end
Span = function (el)
if el.classes:includes 'ftsize' then
return ftsize(el)
end
end For html output it does nothing but my .ftsize {
font-size: 0.8em;
} I have another lua filter Span = function (el)
if el.classes:includes 'citex' then
--return pandoc.Span({"["} .. el.content .. {"]"}, {class="ftsize"})
return ftsize(pandoc.Span({"["} .. el.content .. {"]"}, {class="ftsize"}))
end
end I would like to call the I've tried calling the Here is my test ---
title: "Quarto Basics"
keep-md: true
format:
html:
css: styles.css
pdf:
keep-tex: true
filters:
- footnotesize.lua
- citex.lua
---
Here is an example using ftsize:
[some ref]{.ftsize}
Here is an example using citex:
[some ref]{.citex} Thank you |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Make your function external to your filter and import the Lua module inside your filters. local utils = require("relative/path-to/file.lua") source: https://www.lua.org/pil/8.1.html This being said, I'm not sure to understand why you would make two filters in the first place here while one seems to be enough to handle both cases. |
Beta Was this translation helpful? Give feedback.
Make your function external to your filter and import the Lua module inside your filters.
source: https://www.lua.org/pil/8.1.html
This being said, I'm not sure to understand why you would make two filters in the first place here while one seems to be enough to handle both cases.