Changed -V so that you can specify a key without a value.

Such keys get the value `true`.
This commit is contained in:
John MacFarlane 2012-03-09 10:45:01 -08:00
parent 9766b532f3
commit d4d9504950
2 changed files with 10 additions and 10 deletions

5
README
View file

@ -256,12 +256,13 @@ General writer options
template appropriate for the output format will be used (see
`-D/--print-default-template`).
`-V` *KEY=VAL*, `--variable=`*KEY:VAL*
`-V` *KEY[=VAL]*, `--variable=`*KEY[:VAL]*
: Set the template variable *KEY* to the value *VAL* when rendering the
document in standalone mode. This is generally only useful when the
`--template` option is used to specify a custom template, since
pandoc automatically sets the variables used in the default
templates.
templates. If no *VAL* is specified, the key will be given the
value `true`.
`-D` *FORMAT*, `--print-default-template=`*FORMAT*
: Print the default template for an output *FORMAT*. (See `-t`

View file

@ -295,14 +295,13 @@ options =
, Option "V" ["variable"]
(ReqArg
(\arg opt ->
case break (`elem` ":=") arg of
(k,_:v) -> do
let newvars = optVariables opt ++ [(k,v)]
return opt{ optVariables = newvars }
_ -> err 17 $
"Could not parse `" ++ arg ++ "' as a key/value pair (k=v or k:v)")
"KEY:VALUE")
(\arg opt -> do
let (key,val) = case break (`elem` ":=") arg of
(k,_:v) -> (k,v)
(k,_) -> (k,"true")
let newvars = optVariables opt ++ [(key,val)]
return opt{ optVariables = newvars })
"KEY[:VALUE]")
"" -- "Use custom template"
, Option "D" ["print-default-template"]