git.iko.soy/typeable/pandoc
on master help sign in
Changed --metadata to return Boolean True if no value.

Also documented in README.

commit8977b2aaed096a71e669e1161f6ce10d5286f34e authorJohn MacFarlane <fiddlosopher@gmail.com> dateSun 1 Sep 2013, 16:22 (13 years ago) parent1240edb
2 files changed+14−7
README+6 pandoc.hs+8−7
README+6
@@ -284,6 +284,12 @@ Reader options
284284 if no directory is provided. If you want to run a script in the
285285 working directory, preface the filename with `./`.
286286
287+`-M` *KEY[=VAL]*, `--metadata=`*KEY[:VAL]*
288+: Set the metadata field *KEY* to the value *VAL* after
289+ parsing. A value specified on the command line overrides a value
290+ specified in the document. Values will be interpreted as raw strings.
291+ If no value is specified, the value will be treated as Boolean true.
292+
287293`--normalize`
288294: Normalize the document after reading: merge adjacent
289295 `Str` or `Emph` elements, for example, and remove repeated `Space`s.
pandoc.hs+8−7
@@ -113,7 +113,7 @@ data Opt = Opt
113113 , optTransforms :: [Pandoc -> Pandoc] -- ^ Doc transforms to apply
114114 , optTemplate :: Maybe FilePath -- ^ Custom template
115115 , optVariables :: [(String,String)] -- ^ Template variables to set
116− , optMetadata :: [(String,String)] -- ^ Metadata fields to set
116+ , optMetadata :: [(String,MetaValue)] -- ^ Metadata fields to set
117117 , optOutputFile :: String -- ^ Name of output file
118118 , optNumberSections :: Bool -- ^ Number sections in LaTeX
119119 , optNumberOffset :: [Int] -- ^ Starting number for sections
@@ -328,8 +328,8 @@ options =
328328 (ReqArg
329329 (\arg opt -> do
330330 let (key,val) = case break (`elem` ":=") arg of
331− (k,_:v) -> (k,v)
332− (k,_) -> (k,"true")
331+ (k,_:v) -> (k, MetaString v)
332+ (k,_) -> (k, MetaBool True)
333333 return opt{ optMetadata = (key,val) : optMetadata opt })
334334 "KEY[:VALUE]")
335335 ""
@@ -658,7 +658,7 @@ options =
658658 , Option "" ["bibliography"]
659659 (ReqArg
660660 (\arg opt ->
661− return opt{ optMetadata = ("bibliography",arg) :
661+ return opt{ optMetadata = ("bibliography",MetaString arg) :
662662 optMetadata opt
663663 , optPlugins = externalFilter "pandoc-citeproc"
664664 : optPlugins opt
@@ -669,7 +669,7 @@ options =
669669 , Option "" ["csl"]
670670 (ReqArg
671671 (\arg opt ->
672− return opt{ optMetadata = ("csl",arg) :
672+ return opt{ optMetadata = ("csl", MetaString arg) :
673673 optMetadata opt })
674674 "FILE")
675675 ""
@@ -677,7 +677,8 @@ options =
677677 , Option "" ["citation-abbreviations"]
678678 (ReqArg
679679 (\arg opt ->
680− return opt{ optMetadata = ("citation-abbreviations",arg) :
680+ return opt{ optMetadata = ("citation-abbreviations",
681+ MetaString arg) :
681682 optMetadata opt })
682683 "FILE")
683684 ""
@@ -1104,7 +1105,7 @@ main = do
11041105 reader readerOpts
11051106
11061107
1107− let doc0 = foldr (\(k,v) -> setMeta k (MetaString v)) doc metadata
1108+ let doc0 = foldr (\(k,v) -> setMeta k v) doc metadata
11081109 let doc1 = foldr ($) doc0 transforms
11091110 doc2 <- foldrM ($) doc1 $ map ($ [writerName']) plugins
11101111