@@ -169,6 +169,12 @@ to Pandoc. Or use `html2markdown`(1), a wrapper around `pandoc`.
169169 RTF) or an instruction to create one (LaTeX, reStructuredText).
170170 This option has no effect on man, DocBook, or S5 output.
171171
172+\--template=*FILE*
173+: Use *FILE* as a custom template for the generated document. Implies
174+ `-s`. See TEMPLATES below for a description of template syntax. If
175+ this option is not used, a default template appropriate for the
176+ output format will be used. See also `-D/--print-default-template`.
177+
172178-c *CSS*, \--css=*CSS*
173179: Link to a CSS style sheet. *CSS* is the pathname of the style sheet.
174180
@@ -184,7 +190,8 @@ to Pandoc. Or use `html2markdown`(1), a wrapper around `pandoc`.
184190-C *FILE*, \--custom-header=*FILE*
185191: Use contents of *FILE* as the document header (overriding the
186192 default header, which can be printed by using the `-D` option).
187− Implies `-s`.
193+ Implies `-s`. Note: This option is deprecated. Users should
194+ transition to using `--template` instead.
188195
189196-D *FORMAT*, \--print-default-template=*FORMAT*
190197: Print the default template for an output *FORMAT*. (See `-t`
@@ -219,6 +226,69 @@ to Pandoc. Or use `html2markdown`(1), a wrapper around `pandoc`.
219226-h, \--help
220227: Show usage message.
221228
229+# TEMPLATES
230+
231+When the `-s/--standalone` option is used, pandoc uses a template to
232+add header and footer material that is needed for a self-standing
233+document. To see the default template that is used, just type
234+
235+ pandoc --print-default-template=FORMAT
236+
237+where `FORMAT` is the name of the output format. A custom template
238+can be specified using the `--template` option.
239+
240+Templates may contain *variables*. Variable names are sequences of
241+alphanumerics, `-`, and `_`, starting with a letter. A variable name
242+surrounded by `$` signs will be replaced by its value. For example,
243+the string `$title$` in
244+
245+ <title>$title$</title>
246+
247+will be replaced by the document title.
248+
249+Some variables are set automatically by pandoc. These vary somewhat
250+depending on the output format, but include:
251+
252+`before`
253+: contents specified by `-B/--include-before-body`
254+`after`
255+: contents specified by `-A/--include-after-body`
256+`legacy-header`
257+: contents specified by `-C/--custom-header`
258+`header-includes`
259+: contents specified by `-H/--include-in-header`
260+`toc`
261+: non-null value if `--toc/--table-of-contents` was specified
262+`body`
263+: body of document
264+`title`
265+: title of document, as specified in title block
266+`authors`
267+: authors of document, as specified in title block
268+`date`
269+: date of document, as specified in title block
270+`css`
271+: links to CSS files, as specified using `-c/--css`
272+
273+Variables may be set at the command line using the
274+`--set` option. This allows users to include custom variables in
275+their templates.
276+
277+Templates may contain conditionals. The syntax is as follows:
278+
279+ $if(variable)$
280+ X
281+ $else$
282+ Y
283+ $endif$
284+
285+This will include `X` in the template if `variable` has a non-null
286+value; otherwise it will include `Y`. `X` and `Y` are placeholders for
287+any valid template text, and may include interpolated variables or other
288+conditionals. The `$else$` section may be omitted.
289+
290+To write a literal `$` in a template, use `$$`.
291+
222292# SEE ALSO
223293
224294`hsmarkdown`(1),