@@ -36,6 +36,7 @@ module Text.Pandoc.Readers.Markdown ( readMarkdown ) where
3636import Prelude
3737import Control.Monad
3838import Control.Monad.Except (throwError)
39+import qualified Data.ByteString.Lazy as BS
3940import Data.Char (isAlphaNum, isPunctuation, isSpace, toLower)
4041import Data.List (intercalate, sortBy, transpose, elemIndex)
4142import qualified Data.Map as M
@@ -233,7 +234,6 @@ pandocTitleBlock = try $ do
233234yamlMetaBlock :: PandocMonad m => MarkdownParser m (F Blocks)
234235yamlMetaBlock = try $ do
235236 guardEnabled Ext_yaml_metadata_block
236− pos <- getPosition
237237 string "---"
238238 blankline
239239 notFollowedBy blankline -- if --- is followed by a blank it's an HRULE
@@ -241,8 +241,13 @@ yamlMetaBlock = try $ do
241241 -- by including --- and ..., we allow yaml blocks with just comments:
242242 let rawYaml = unlines ("---" : (rawYamlLines ++ ["..."]))
243243 optional blanklines
244− case YAML.decodeNode' YAML.failsafeSchemaResolver False False
245− (UTF8.fromStringLazy rawYaml) of
244+ yamlBsToMeta $ UTF8.fromStringLazy rawYaml
245+ return mempty
246+
247+yamlBsToMeta :: PandocMonad m => BS.ByteString -> MarkdownParser m ()
248+yamlBsToMeta bstr = do
249+ pos <- getPosition
250+ case YAML.decodeNode' YAML.failsafeSchemaResolver False False bstr of
246251 Right [YAML.Doc (YAML.Mapping _ hashmap)] ->
247252 mapM_ (\(key, v) -> do
248253 k <- nodeToKey key
@@ -271,7 +276,6 @@ yamlMetaBlock = try $ do
271276 logMessage $ CouldNotParseYamlMetadata
272277 err' pos
273278 return ()
274− return mempty
275279
276280nodeToKey :: Monad m => YAML.Node -> m Text
277281nodeToKey (YAML.Scalar (YAML.SStr t)) = return t