diff options
Diffstat (limited to 'src/Text/Pandoc/Readers/Markdown.hs')
-rw-r--r-- | src/Text/Pandoc/Readers/Markdown.hs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index 1a4c63de0..d8296ea61 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -67,11 +67,17 @@ readMarkdown opts s = do -- String scalars in the YAML are parsed as Markdown. yamlToMeta :: PandocMonad m => ReaderOptions + -> Maybe FilePath -> BL.ByteString -> m Meta -yamlToMeta opts bstr = do +yamlToMeta opts mbfp bstr = do let parser = do + oldPos <- getPosition + case mbfp of + Nothing -> return () + Just fp -> setPosition $ initialPos fp meta <- yamlBsToMeta (fmap B.toMetaValue <$> parseBlocks) bstr + setPosition oldPos return $ runF meta defaultParserState parsed <- readWithM parser def{ stateOptions = opts } "" case parsed of @@ -84,11 +90,17 @@ yamlToMeta opts bstr = do yamlToRefs :: PandocMonad m => (Text -> Bool) -> ReaderOptions + -> Maybe FilePath -> BL.ByteString -> m [MetaValue] -yamlToRefs idpred opts bstr = do +yamlToRefs idpred opts mbfp bstr = do let parser = do + oldPos <- getPosition + case mbfp of + Nothing -> return () + Just fp -> setPosition $ initialPos fp refs <- yamlBsToRefs (fmap B.toMetaValue <$> parseBlocks) idpred bstr + setPosition oldPos return $ runF refs defaultParserState parsed <- readWithM parser def{ stateOptions = opts } "" case parsed of |