Added -V/--variable option to set custom template variables.
git-svn-id: https://pandoc.googlecode.com/svn/trunk@1685 788f1e2b-df1e-0410-8736-df70ead52e1b
This commit is contained in:
parent
9f126c15cf
commit
b771051432
5 changed files with 43 additions and 8 deletions
13
README
13
README
|
@ -289,6 +289,13 @@ For further documentation, see the `pandoc(1)` man page.
|
||||||
template appropriate for the output format will be used. See also
|
template appropriate for the output format will be used. See also
|
||||||
`-D/--print-default-template`.
|
`-D/--print-default-template`.
|
||||||
|
|
||||||
|
`-V` *key=val*, `--variable=`*key:val*
|
||||||
|
: sets the template variable *key* to the value *val* when rendering the
|
||||||
|
document in standalone mode. This is only useful when the
|
||||||
|
`--template` option is used to specify a custom template, since
|
||||||
|
pandoc automatically sets the variables used in the default
|
||||||
|
templates.
|
||||||
|
|
||||||
`-c` or `--css` *filename*
|
`-c` or `--css` *filename*
|
||||||
: allows the user to specify a custom stylesheet that will be linked to
|
: allows the user to specify a custom stylesheet that will be linked to
|
||||||
in HTML and S5 output. This option can be used repeatedly to include
|
in HTML and S5 output. This option can be used repeatedly to include
|
||||||
|
@ -489,9 +496,9 @@ depending on the output format, but include:
|
||||||
`css`
|
`css`
|
||||||
: links to CSS files, as specified using `-c/--css`
|
: links to CSS files, as specified using `-c/--css`
|
||||||
|
|
||||||
Variables may be set at the command line using the
|
Variables may be set at the command line using the `-V/--variable`
|
||||||
`--set` option. This allows users to include custom variables in
|
option. This allows users to include custom variables in their
|
||||||
their templates.
|
templates.
|
||||||
|
|
||||||
Templates may contain conditionals. The syntax is as follows:
|
Templates may contain conditionals. The syntax is as follows:
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,13 @@ The following options are most relevant:
|
||||||
`-s`. See the section TEMPLATES in `pandoc`(1) for information about
|
`-s`. See the section TEMPLATES in `pandoc`(1) for information about
|
||||||
template syntax.
|
template syntax.
|
||||||
|
|
||||||
|
-V KEY=VAL, \--variable=*KEY:VAL*
|
||||||
|
: Set the template variable KEY to the value VAL when rendering the
|
||||||
|
document in standalone mode. This is only useful when the
|
||||||
|
`--template` option is used to specify a custom template, since
|
||||||
|
pandoc automatically sets the variables used in the default
|
||||||
|
templates.
|
||||||
|
|
||||||
-H *FILE*, \--include-in-header=*FILE*
|
-H *FILE*, \--include-in-header=*FILE*
|
||||||
: Include (LaTeX) contents of *FILE* at the end of the header. Implies
|
: Include (LaTeX) contents of *FILE* at the end of the header. Implies
|
||||||
`-s`.
|
`-s`.
|
||||||
|
|
|
@ -175,6 +175,13 @@ to Pandoc. Or use `html2markdown`(1), a wrapper around `pandoc`.
|
||||||
this option is not used, a default template appropriate for the
|
this option is not used, a default template appropriate for the
|
||||||
output format will be used. See also `-D/--print-default-template`.
|
output format will be used. See also `-D/--print-default-template`.
|
||||||
|
|
||||||
|
-V KEY=VAL, \--variable=*KEY:VAL*
|
||||||
|
: Set the template variable KEY to the value VAL when rendering the
|
||||||
|
document in standalone mode. This is only useful when the
|
||||||
|
`--template` option is used to specify a custom template, since
|
||||||
|
pandoc automatically sets the variables used in the default
|
||||||
|
templates.
|
||||||
|
|
||||||
-c *CSS*, \--css=*CSS*
|
-c *CSS*, \--css=*CSS*
|
||||||
: Link to a CSS style sheet. *CSS* is the pathname of the style sheet.
|
: Link to a CSS style sheet. *CSS* is the pathname of the style sheet.
|
||||||
|
|
||||||
|
@ -270,9 +277,9 @@ depending on the output format, but include:
|
||||||
`css`
|
`css`
|
||||||
: links to CSS files, as specified using `-c/--css`
|
: links to CSS files, as specified using `-c/--css`
|
||||||
|
|
||||||
Variables may be set at the command line using the
|
Variables may be set at the command line using the `-V/--variable`
|
||||||
`--set` option. This allows users to include custom variables in
|
option. This allows users to include custom variables in their
|
||||||
their templates.
|
templates.
|
||||||
|
|
||||||
Templates may contain conditionals. The syntax is as follows:
|
Templates may contain conditionals. The syntax is as follows:
|
||||||
|
|
||||||
|
|
|
@ -152,13 +152,14 @@ main = bracket
|
||||||
unless (null miss) $ exit $! "Could not find " ++ intercalate ", " miss
|
unless (null miss) $ exit $! "Could not find " ++ intercalate ", " miss
|
||||||
args <- getArgs
|
args <- getArgs
|
||||||
-- check for invalid arguments and print help message if needed
|
-- check for invalid arguments and print help message if needed
|
||||||
let goodopts = ["-f","-r","-N", "-p","-R","-H","-B","-A", "-C","-o"]
|
let goodopts = ["-f","-r","-N", "-p","-R","-H","-B","-A", "-C","-o","-V"]
|
||||||
let goodoptslong = ["--from","--read","--strict",
|
let goodoptslong = ["--from","--read","--strict",
|
||||||
"--preserve-tabs","--tab-stop","--parse-raw",
|
"--preserve-tabs","--tab-stop","--parse-raw",
|
||||||
"--toc","--table-of-contents",
|
"--toc","--table-of-contents",
|
||||||
"--number-sections","--include-in-header",
|
"--number-sections","--include-in-header",
|
||||||
"--include-before-body","--include-after-body",
|
"--include-before-body","--include-after-body",
|
||||||
"--custom-header","--output"]
|
"--custom-header","--output",
|
||||||
|
"--template", "--variable"]
|
||||||
let isOpt ('-':_) = True
|
let isOpt ('-':_) = True
|
||||||
isOpt _ = False
|
isOpt _ = False
|
||||||
let opts = filter isOpt args
|
let opts = filter isOpt args
|
||||||
|
|
|
@ -339,6 +339,19 @@ options =
|
||||||
"FILENAME")
|
"FILENAME")
|
||||||
"" -- "Use custom template"
|
"" -- "Use custom template"
|
||||||
|
|
||||||
|
, Option "V" ["variable"]
|
||||||
|
(ReqArg
|
||||||
|
(\arg opt ->
|
||||||
|
case break (`elem` ":=") arg of
|
||||||
|
(k,_:v) -> do
|
||||||
|
let newvars = (k, v) : optVariables opt
|
||||||
|
return opt{ optVariables = newvars }
|
||||||
|
_ -> do
|
||||||
|
hPutStrLn stderr $ "Could not parse `" ++ arg ++ "' as a key/value pair (k=v or k:v)"
|
||||||
|
exitWith $ ExitFailure 17)
|
||||||
|
"FILENAME")
|
||||||
|
"" -- "Use custom template"
|
||||||
|
|
||||||
, Option "c" ["css"]
|
, Option "c" ["css"]
|
||||||
(ReqArg
|
(ReqArg
|
||||||
(\arg opt -> do
|
(\arg opt -> do
|
||||||
|
|
Loading…
Add table
Reference in a new issue