@@ -37,21 +37,19 @@ yamlBsToMeta :: PandocMonad m
3737 -> BL.ByteString
3838 -> ParserT Text ParserState m (F Meta)
3939yamlBsToMeta pMetaValue bstr = do
40− pos <- getPosition
4140 case YAML.decodeNode' YAML.failsafeSchemaResolver False False bstr of
4241 Right (YAML.Doc (YAML.Mapping _ _ o):_)
4342 -> fmap Meta <$> yamlMap pMetaValue o
4443 Right [] -> return . return $ mempty
4544 Right [YAML.Doc (YAML.Scalar _ YAML.SNull)]
4645 -> return . return $ mempty
47− Right _ -> do logMessage $ CouldNotParseYamlMetadata "not an object"
48− pos
49− return . return $ mempty
50− Left (_pos, err')
51− -> do logMessage $ CouldNotParseYamlMetadata
52− (T.pack err') pos
53− return . return $ mempty
54−
46+ Right _ -> fail "expected YAML object"
47+ Left (yamlpos, err')
48+ -> do pos <- getPosition
49+ setPosition $ incSourceLine
50+ (setSourceColumn pos (YE.posColumn yamlpos))
51+ (YE.posLine yamlpos - 1)
52+ fail err'
5553
5654fakePos :: YAML.Pos
5755fakePos = YAML.Pos (-1) (-1) 1 0
@@ -71,8 +69,7 @@ yamlBsToRefs :: PandocMonad m
7169 -> (Text -> Bool) -- ^ Filter for id
7270 -> BL.ByteString
7371 -> ParserT Text ParserState m (F [MetaValue])
74−yamlBsToRefs pMetaValue idpred bstr = do
75− pos <- getPosition
72+yamlBsToRefs pMetaValue idpred bstr =
7673 case YAML.decodeNode' YAML.failsafeSchemaResolver False False bstr of
7774 Right (YAML.Doc o@(YAML.Mapping _ _ _):_)
7875 -> case lookupYAML "references" o of
@@ -90,26 +87,17 @@ yamlBsToRefs pMetaValue idpred bstr = do
9087 Nothing -> False
9188 sequence <$>
9289 mapM (yamlToMetaValue pMetaValue) (filter g ns)
93− Just _ -> do
94− logMessage $ CouldNotParseYamlMetadata
95− ("expecting sequence in 'references' field") pos
96− return . return $ mempty
97− Nothing -> do
98− logMessage $ CouldNotParseYamlMetadata
99− ("expecting 'references' field") pos
100− return . return $ mempty
90+ Just _ ->
91+ fail "expecting sequence in 'references' field"
92+ Nothing ->
93+ fail "expecting 'references' field"
10194
10295 Right [] -> return . return $ mempty
10396 Right [YAML.Doc (YAML.Scalar _ YAML.SNull)]
10497 -> return . return $ mempty
105− Right _ -> do logMessage $ CouldNotParseYamlMetadata "not an object"
106− pos
107− return . return $ mempty
98+ Right _ -> fail "expecting YAML object"
10899 Left (_pos, err')
109− -> do logMessage $ CouldNotParseYamlMetadata
110− (T.pack err') pos
111− return . return $ mempty
112−
100+ -> fail err'
113101
114102
115103nodeToKey :: YAML.Node YE.Pos -> Maybe Text