Pandoc can use a YAML header in Markdown or a defaults or metadata file for all source types where one can store variables to use in the template. Is it possible to not escape backslashes and LaTeX commands inside these metadata variables?
For example, I'd have this line in my YAML header: phone: +49\,123\,456789
. When converting, Pandoc escapes the backslashes, so it becomes +49\textbackslash,123\textbackslash,456789
. This is unwanted, as I want LaTeX to interpret \,
and turn it into thin spaces.
I also tried wrapping it in ''
or as block with |
, so YAML itself doesn't escape anything, but this seems to be Pandoc itself doing the conversion, not the YAML interpreter.
src.md:
Some text
defaults.yaml:
template: ./tpl.tex
metadata:
phone: +49\,123\,456789
tpl.tex:
Phone number: $phone$
Markdown body:
$body$
Output with pandoc --defaults defaults.yaml src.md --to latex
:
Phone number: +49\textbackslash,123\textbackslash,456789
Markdown body:
Some text
Should be:
Phone number: +49\,123\,456789
Markdown body:
Some text
Metadata will always be escaped; the easiest way is to do what you want is to define a variable instead of metadata.
---
variables:
phone: +49\,123\,456789
---
Contrary to metadata values, variables are inserted verbatim into the template.