aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2021-05-12 06:01:13 -0600
committerJohn MacFarlane <jgm@berkeley.edu>2021-05-12 06:01:13 -0600
commit46309319ef9eb66ea3598073df4174fb40b1b0f8 (patch)
tree295dd1d0a4e8c34ed03c89d18ddb0a71ce6462dc /src
parent5eb7ad7d1ebbfe27a282a2d75f199bacf2052be3 (diff)
downloadpandoc-46309319ef9eb66ea3598073df4174fb40b1b0f8.tar.gz
Fix source position reporting for YAML bibliographies.
Closes #7273.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Readers/Markdown.hs2
-rw-r--r--src/Text/Pandoc/Readers/Metadata.hs8
2 files changed, 6 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs
index 69dd51bc4..2d20ff018 100644
--- a/src/Text/Pandoc/Readers/Markdown.hs
+++ b/src/Text/Pandoc/Readers/Markdown.hs
@@ -97,12 +97,10 @@ yamlToRefs :: PandocMonad m
-> m [MetaValue]
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 } ("" :: Text)
case parsed of
diff --git a/src/Text/Pandoc/Readers/Metadata.hs b/src/Text/Pandoc/Readers/Metadata.hs
index bbcfe62ea..45eddf25a 100644
--- a/src/Text/Pandoc/Readers/Metadata.hs
+++ b/src/Text/Pandoc/Readers/Metadata.hs
@@ -98,8 +98,12 @@ yamlBsToRefs pMetaValue idpred bstr =
Right [YAML.Doc (YAML.Scalar _ YAML.SNull)]
-> return . return $ mempty
Right _ -> Prelude.fail "expecting YAML object"
- Left (_pos, err')
- -> Prelude.fail err'
+ Left (yamlpos, err')
+ -> do pos <- getPosition
+ setPosition $ incSourceLine
+ (setSourceColumn pos (YE.posColumn yamlpos))
+ (YE.posLine yamlpos - 1)
+ Prelude.fail err'
nodeToKey :: YAML.Node YE.Pos -> Maybe Text