git.iko.soy/typeable/pandoc
on master help sign in
Add `sourcefile` and `outputfile` template variables (#3439)
699d289Roland Hieber
MANUAL.txt+16
@@ -1074,6 +1074,22 @@ Some variables are set automatically by pandoc. These vary somewhat
1074depending on the output format, but include metadata fields as well
1074depending on the output format, but include metadata fields as well
1075as the following:
1075as the following:
1076
1076
1077+`sourcefile`, `outputfile`
1078+: source and destination filenames, as given on the command line.
1079+ `sourcefile` can also be a list if input comes from multiple files, or empty
1080+ if input is from stdin. You can use the following snippet in your template
1081+ to distinguish them:
1082+
1083+ $if(sourcefile)$
1084+ $for(sourcefile)$
1085+ $sourcefile$
1086+ $endfor$
1087+ $else$
1088+ (stdin)
1089+ $endif$
1090+
1091+ Similarly, `outputfile` can be `-` if output goes to the terminal.
1092+
1077`title`, `author`, `date`
1093`title`, `author`, `date`
1078: allow identification of basic aspects of the document. Included
1094: allow identification of basic aspects of the document. Included
1079 in PDF metadata through LaTeX and ConTeXt. These can be set
1095 in PDF metadata through LaTeX and ConTeXt. These can be set
src/Text/Pandoc/App.hs+5
@@ -230,6 +230,11 @@ convertWithOpts opts = do
230
230
231 variables <- return (optVariables opts)
231 variables <- return (optVariables opts)
232 >>=
232 >>=
233+ (\vars -> return $ ("outputfile", optOutputFile opts) : vars)
234+ >>=
235+ withList (addStringAsVariable "sourcefile")
236+ (optInputFiles opts)
237+ >>=
233 withList (addContentsAsVariable "include-before")
238 withList (addContentsAsVariable "include-before")
234 (optIncludeBeforeBody opts)
239 (optIncludeBeforeBody opts)
235 >>=
240 >>=