diff options
-rw-r--r-- | README | 5 | ||||
-rw-r--r-- | src/pandoc.hs | 15 |
2 files changed, 10 insertions, 10 deletions
@@ -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` diff --git a/src/pandoc.hs b/src/pandoc.hs index be65c8856..dab7b4161 100644 --- a/src/pandoc.hs +++ b/src/pandoc.hs @@ -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"] |