TeX - LaTeX Asked by Septatrix on March 7, 2021
I would like to include the content of an environment variable inside a PDFs metadata. (More specifically the commit inside of a CI pipeline). To do this I used an old(ish) macro of mine to get the value of environment variables using sys_get_shell:nnN
+ kpsewhich --var-value
.
Surprisingly this works when storing the result inside an intermediate variable but not when using the output directly. The screenshot shows the metadata information as reported by TeXstudio.
MWE:
documentclass{article}
usepackage{hyperref}
usepackage{xparse}
ExplSyntaxOn
NewDocumentCommand getenv { o m }
{
sys_get_shell:nnN { kpsewhich ~ --var-value ~ #2 } { } l_tmpa_tl
tl_trim_spaces:N l_tmpa_tl
IfNoValueTF { #1 }{
tl_to_str:N l_tmpa_tl
}{
tl_set_eq:NN #1 l_tmpa_tl
}
}
ExplSyntaxOff
getenv[LANG]{LANG}
hypersetup{
pdfinfo={
LangIndirect=LANG,
LangDirect=getenv{LANG},
},
}
begin{document}
ExplSyntaxOn
tl_to_str:N l_tmpa_tl
ExplSyntaxOff
end{document}
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP