@@ -37,21 +37,19 @@ yamlBsToMeta :: PandocMonad m
37 -> BL.ByteString
37 -> BL.ByteString
38 -> ParserT Text ParserState m (F Meta)
38 -> ParserT Text ParserState m (F Meta)
39yamlBsToMeta pMetaValue bstr = do
39yamlBsToMeta pMetaValue bstr = do
41 case YAML.decodeNode' YAML.failsafeSchemaResolver False False bstr of
40 case YAML.decodeNode' YAML.failsafeSchemaResolver False False bstr of
42 Right (YAML.Doc (YAML.Mapping _ _ o):_)
41 Right (YAML.Doc (YAML.Mapping _ _ o):_)
43 -> fmap Meta <$> yamlMap pMetaValue o
42 -> fmap Meta <$> yamlMap pMetaValue o
44 Right [] -> return . return $ mempty
43 Right [] -> return . return $ mempty
45 Right [YAML.Doc (YAML.Scalar _ YAML.SNull)]
44 Right [YAML.Doc (YAML.Scalar _ YAML.SNull)]
46 -> return . return $ mempty
45 -> return . return $ mempty
47− Right _ -> do logMessage $ CouldNotParseYamlMetadata "not an object"
46+ Right _ -> fail "expected YAML object"
49− return . return $ mempty
50− Left (_pos, err')
47+ Left (yamlpos, err')
51− -> do logMessage $ CouldNotParseYamlMetadata
48+ -> do pos <- getPosition
52− (T.pack err') pos
49+ setPosition $ incSourceLine
53− return . return $ mempty
50+ (setSourceColumn pos (YE.posColumn yamlpos))
54−
51+ (YE.posLine yamlpos - 1)
56fakePos :: YAML.Pos
54fakePos :: YAML.Pos
57fakePos = YAML.Pos (-1) (-1) 1 0
55fakePos = YAML.Pos (-1) (-1) 1 0
@@ -71,8 +69,7 @@ yamlBsToRefs :: PandocMonad m
71 -> (Text -> Bool) -- ^ Filter for id
69 -> (Text -> Bool) -- ^ Filter for id
72 -> BL.ByteString
70 -> BL.ByteString
73 -> ParserT Text ParserState m (F [MetaValue])
71 -> ParserT Text ParserState m (F [MetaValue])
74−yamlBsToRefs pMetaValue idpred bstr = do
72+yamlBsToRefs pMetaValue idpred bstr =
76 case YAML.decodeNode' YAML.failsafeSchemaResolver False False bstr of
73 case YAML.decodeNode' YAML.failsafeSchemaResolver False False bstr of
77 Right (YAML.Doc o@(YAML.Mapping _ _ _):_)
74 Right (YAML.Doc o@(YAML.Mapping _ _ _):_)
78 -> case lookupYAML "references" o of
75 -> case lookupYAML "references" o of
@@ -90,26 +87,17 @@ yamlBsToRefs pMetaValue idpred bstr = do
90 Nothing -> False
87 Nothing -> False
91 sequence <$>
88 sequence <$>
92 mapM (yamlToMetaValue pMetaValue) (filter g ns)
89 mapM (yamlToMetaValue pMetaValue) (filter g ns)
93− Just _ -> do
90+ Just _ ->
94− logMessage $ CouldNotParseYamlMetadata
95− ("expecting sequence in 'references' field") pos
91+ fail "expecting sequence in 'references' field"
96− return . return $ mempty
97− Nothing -> do
92+ Nothing ->
98− logMessage $ CouldNotParseYamlMetadata
99− ("expecting 'references' field") pos
93+ fail "expecting 'references' field"
100− return . return $ mempty
102 Right [] -> return . return $ mempty
95 Right [] -> return . return $ mempty
103 Right [YAML.Doc (YAML.Scalar _ YAML.SNull)]
96 Right [YAML.Doc (YAML.Scalar _ YAML.SNull)]
104 -> return . return $ mempty
97 -> return . return $ mempty
105− Right _ -> do logMessage $ CouldNotParseYamlMetadata "not an object"
98+ Right _ -> fail "expecting YAML object"
107− return . return $ mempty
108 Left (_pos, err')
99 Left (_pos, err')
109− -> do logMessage $ CouldNotParseYamlMetadata
100+ -> fail err'
111− return . return $ mempty
115nodeToKey :: YAML.Node YE.Pos -> Maybe Text
103nodeToKey :: YAML.Node YE.Pos -> Maybe Text