git.iko.soy/typeable/pandoc
on master help sign in
Allow YAML title blocks to contain only comments.
d44d166John MacFarlane
src/Text/Pandoc/Readers/Markdown.hs+4−1
@@ -231,7 +231,9 @@ yamlTitleBlock = try $ do
231 pos <- getPosition
231 pos <- getPosition
232 string "---"
232 string "---"
233 blankline
233 blankline
234− rawYaml <- unlines <$> manyTill anyLine stopLine
234+ rawYamlLines <- manyTill anyLine stopLine
235+ -- by including --- and ..., we allow yaml blocks with just comments:
236+ let rawYaml = unlines ("---" : (rawYamlLines ++ ["..."]))
235 optional blanklines
237 optional blanklines
236 opts <- stateOptions <$> getState
238 opts <- stateOptions <$> getState
237 case Yaml.decodeEither' $ UTF8.fromString rawYaml of
239 case Yaml.decodeEither' $ UTF8.fromString rawYaml of
@@ -241,6 +243,7 @@ yamlTitleBlock = try $ do
241 then f
243 then f
242 else B.setMeta (T.unpack k) (yamlToMeta opts v) . f)
244 else B.setMeta (T.unpack k) (yamlToMeta opts v) . f)
243 id hashmap
245 id hashmap
246+ Right Yaml.Null -> return $ return id
244 Right _ -> do
247 Right _ -> do
245 addWarning (Just pos) "YAML header is not an object"
248 addWarning (Just pos) "YAML header is not an object"
246 return $ return id
249 return $ return id