git.iko.soy/typeable/pandoc
on master help sign in
Changed --metadata to return Boolean True if no value.
8977b2aJohn MacFarlane
@@ -284,6 +284,12 @@ Reader options
284 if no directory is provided. If you want to run a script in the
284 if no directory is provided. If you want to run a script in the
285 working directory, preface the filename with `./`.
285 working directory, preface the filename with `./`.
286
286
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+
287`--normalize`
293`--normalize`
288: Normalize the document after reading: merge adjacent
294: Normalize the document after reading: merge adjacent
289 `Str` or `Emph` elements, for example, and remove repeated `Space`s.
295 `Str` or `Emph` elements, for example, and remove repeated `Space`s.
pandoc.hs+8−7
@@ -113,7 +113,7 @@ data Opt = Opt
113 , optTransforms :: [Pandoc -> Pandoc] -- ^ Doc transforms to apply
113 , optTransforms :: [Pandoc -> Pandoc] -- ^ Doc transforms to apply
114 , optTemplate :: Maybe FilePath -- ^ Custom template
114 , optTemplate :: Maybe FilePath -- ^ Custom template
115 , optVariables :: [(String,String)] -- ^ Template variables to set
115 , optVariables :: [(String,String)] -- ^ Template variables to set
116− , optMetadata :: [(String,String)] -- ^ Metadata fields to set
116+ , optMetadata :: [(String,MetaValue)] -- ^ Metadata fields to set
117 , optOutputFile :: String -- ^ Name of output file
117 , optOutputFile :: String -- ^ Name of output file
118 , optNumberSections :: Bool -- ^ Number sections in LaTeX
118 , optNumberSections :: Bool -- ^ Number sections in LaTeX
119 , optNumberOffset :: [Int] -- ^ Starting number for sections
119 , optNumberOffset :: [Int] -- ^ Starting number for sections
@@ -328,8 +328,8 @@ options =
328 (ReqArg
328 (ReqArg
329 (\arg opt -> do
329 (\arg opt -> do
330 let (key,val) = case break (`elem` ":=") arg of
330 let (key,val) = case break (`elem` ":=") arg of
331− (k,_:v) -> (k,v)
331+ (k,_:v) -> (k, MetaString v)
332− (k,_) -> (k,"true")
332+ (k,_) -> (k, MetaBool True)
333 return opt{ optMetadata = (key,val) : optMetadata opt })
333 return opt{ optMetadata = (key,val) : optMetadata opt })
334 "KEY[:VALUE]")
334 "KEY[:VALUE]")
335 ""
335 ""
@@ -658,7 +658,7 @@ options =
658 , Option "" ["bibliography"]
658 , Option "" ["bibliography"]
659 (ReqArg
659 (ReqArg
660 (\arg opt ->
660 (\arg opt ->
661− return opt{ optMetadata = ("bibliography",arg) :
661+ return opt{ optMetadata = ("bibliography",MetaString arg) :
662 optMetadata opt
662 optMetadata opt
663 , optPlugins = externalFilter "pandoc-citeproc"
663 , optPlugins = externalFilter "pandoc-citeproc"
664 : optPlugins opt
664 : optPlugins opt
@@ -669,7 +669,7 @@ options =
669 , Option "" ["csl"]
669 , Option "" ["csl"]
670 (ReqArg
670 (ReqArg
671 (\arg opt ->
671 (\arg opt ->
672− return opt{ optMetadata = ("csl",arg) :
672+ return opt{ optMetadata = ("csl", MetaString arg) :
673 optMetadata opt })
673 optMetadata opt })
674 "FILE")
674 "FILE")
675 ""
675 ""
@@ -677,7 +677,8 @@ options =
677 , Option "" ["citation-abbreviations"]
677 , Option "" ["citation-abbreviations"]
678 (ReqArg
678 (ReqArg
679 (\arg opt ->
679 (\arg opt ->
680− return opt{ optMetadata = ("citation-abbreviations",arg) :
680+ return opt{ optMetadata = ("citation-abbreviations",
681+ MetaString arg) :
681 optMetadata opt })
682 optMetadata opt })
682 "FILE")
683 "FILE")
683 ""
684 ""
@@ -1104,7 +1105,7 @@ main = do
1104 reader readerOpts
1105 reader readerOpts
1105
1106
1106
1107
1107− let doc0 = foldr (\(k,v) -> setMeta k (MetaString v)) doc metadata
1108+ let doc0 = foldr (\(k,v) -> setMeta k v) doc metadata
1108 let doc1 = foldr ($) doc0 transforms
1109 let doc1 = foldr ($) doc0 transforms
1109 doc2 <- foldrM ($) doc1 $ map ($ [writerName']) plugins
1110 doc2 <- foldrM ($) doc1 $ map ($ [writerName']) plugins
1110
1111