Skip to content

Commit

Permalink
Add sourcefile and outputfile template variables (#3439)
Browse files Browse the repository at this point in the history
Closes #3431.
  • Loading branch information
rohieb authored and jgm committed Feb 25, 2017
1 parent 9ab30c6 commit 699d289
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
16 changes: 16 additions & 0 deletions MANUAL.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1074,6 +1074,22 @@ Some variables are set automatically by pandoc. These vary somewhat
depending on the output format, but include metadata fields as well
as the following:

`sourcefile`, `outputfile`
: source and destination filenames, as given on the command line.
`sourcefile` can also be a list if input comes from multiple files, or empty
if input is from stdin. You can use the following snippet in your template
to distinguish them:

$if(sourcefile)$
$for(sourcefile)$
$sourcefile$
$endfor$
$else$
(stdin)
$endif$

Similarly, `outputfile` can be `-` if output goes to the terminal.

`title`, `author`, `date`
: allow identification of basic aspects of the document. Included
in PDF metadata through LaTeX and ConTeXt. These can be set
Expand Down
5 changes: 5 additions & 0 deletions src/Text/Pandoc/App.hs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,11 @@ convertWithOpts opts = do

variables <- return (optVariables opts)
>>=
(\vars -> return $ ("outputfile", optOutputFile opts) : vars)
>>=
withList (addStringAsVariable "sourcefile")
(optInputFiles opts)
>>=
withList (addContentsAsVariable "include-before")
(optIncludeBeforeBody opts)
>>=
Expand Down

0 comments on commit 699d289

Please sign in to comment.