Pre-processing text in \markdownInput using lua function #252
-
I'm using a custom Lua function to do variable replacement in the style of pandoc-mustache, but performed directly in LuaLaTeX. This provides a convenient way to get variable replacement working in Overleaf, which is important for keeping my coauthors happy (who don't enjoy editing plain text markdown files 😅) I haven't been able to figure out how to apply my Lua function to pre-process markdown text inserted via
Minimal examplevariable-replacement.tex
test.md
Typeset Output: |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
It seems to me that you are missing a s = s:gsub ( "{{s*variable%s*}}" , "successful test" ) Otherwise, your solution should work. If you'd like your solution to work with the Another solution would be to redefine the macro that renders left braces and do the variable expansion in TeX. This will also work with both |
Beta Was this translation helpful? Give feedback.
It seems to me that you are missing a
%
before thes*
in the following line:Otherwise, your solution should work. If you'd like your solution to work with the
\markdownInput
command as well and can grok using LPEG instead of regular expressions, then writing a user-defined syntax extension may be more appropriate.Another solution would be to redefine the macro that renders left braces and do the variable expansion in TeX. This will also work with both
\begin{markdown} ... \end{markdown}
and\markdownInput
, similarly to syntax extensions.