summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <fiddlosopher@gmail.com>2012-03-09 10:45:01 -0800
committerJohn MacFarlane <fiddlosopher@gmail.com>2012-03-09 10:45:01 -0800
commitd4d9504950c71fdc4992a9597d2ec06adb8150db (patch)
treeb6d568545b41906397866bc0163d319703848ec6
parent9766b532f38266d0606520fcbfb0c13fd5b09a2f (diff)
Changed -V so that you can specify a key without a value.
Such keys get the value `true`.
-rw-r--r--README5
-rw-r--r--src/pandoc.hs15
2 files changed, 10 insertions, 10 deletions
diff --git a/README b/README
index f32596af2..12f1d9c61 100644
--- a/README
+++ b/README
@@ -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"]