git.iko.soy/typeable/pandoc
on master help sign in
T.P.Readers.Metadata: made `yamlBsToMeta`, `yamlBsToRefs` polymorphic...

on the parser state, instead of requiring ParserState. [API change]

commit4d041953f56b85d4db241cea11c764856ccbeebe authorJohn MacFarlane <jgm@berkeley.edu> dateSat 20 Mar 2021, 10:41 (6 years ago) parent84d8f3e
1 file changed+15−15
src/Text/Pandoc/Readers/Metadata.hs+15−15
src/Text/Pandoc/Readers/Metadata.hs+15−15
@@ -31,10 +31,10 @@ import Text.Pandoc.Error
3131import Text.Pandoc.Parsing hiding (tableWith)
3232import Text.Pandoc.Shared
3333
34−yamlBsToMeta :: PandocMonad m
35− => ParserT Text ParserState m (F MetaValue)
34+yamlBsToMeta :: (PandocMonad m, HasLastStrPosition st)
35+ => ParserT Text st m (Future st MetaValue)
3636 -> BL.ByteString
37− -> ParserT Text ParserState m (F Meta)
37+ -> ParserT Text st m (Future st Meta)
3838yamlBsToMeta pMetaValue bstr = do
3939 case YAML.decodeNode' YAML.failsafeSchemaResolver False False bstr of
4040 Right (YAML.Doc (YAML.Mapping _ _ o):_)
@@ -63,11 +63,11 @@ lookupYAML t (YAML.Mapping _ _ m) =
6363lookupYAML _ _ = Nothing
6464
6565-- Returns filtered list of references.
66−yamlBsToRefs :: PandocMonad m
67− => ParserT Text ParserState m (F MetaValue)
66+yamlBsToRefs :: (PandocMonad m, HasLastStrPosition st)
67+ => ParserT Text st m (Future st MetaValue)
6868 -> (Text -> Bool) -- ^ Filter for id
6969 -> BL.ByteString
70− -> ParserT Text ParserState m (F [MetaValue])
70+ -> ParserT Text st m (Future st [MetaValue])
7171yamlBsToRefs pMetaValue idpred bstr =
7272 case YAML.decodeNode' YAML.failsafeSchemaResolver False False bstr of
7373 Right (YAML.Doc o@YAML.Mapping{}:_)
@@ -104,10 +104,10 @@ nodeToKey (YAML.Scalar _ (YAML.SStr t)) = Just t
104104nodeToKey (YAML.Scalar _ (YAML.SUnknown _ t)) = Just t
105105nodeToKey _ = Nothing
106106
107−normalizeMetaValue :: PandocMonad m
108− => ParserT Text ParserState m (F MetaValue)
107+normalizeMetaValue :: (PandocMonad m, HasLastStrPosition st)
108+ => ParserT Text st m (Future st MetaValue)
109109 -> Text
110− -> ParserT Text ParserState m (F MetaValue)
110+ -> ParserT Text st m (Future st MetaValue)
111111normalizeMetaValue pMetaValue x =
112112 -- Note: a standard quoted or unquoted YAML value will
113113 -- not end in a newline, but a "block" set off with
@@ -129,10 +129,10 @@ checkBoolean t
129129 | t == T.pack "false" || t == T.pack "False" || t == T.pack "FALSE" = Just False
130130 | otherwise = Nothing
131131
132−yamlToMetaValue :: PandocMonad m
133− => ParserT Text ParserState m (F MetaValue)
132+yamlToMetaValue :: (PandocMonad m, HasLastStrPosition st)
133+ => ParserT Text st m (Future st MetaValue)
134134 -> YAML.Node YE.Pos
135− -> ParserT Text ParserState m (F MetaValue)
135+ -> ParserT Text st m (Future st MetaValue)
136136yamlToMetaValue pMetaValue (YAML.Scalar _ x) =
137137 case x of
138138 YAML.SStr t -> normalizeMetaValue pMetaValue t
@@ -152,10 +152,10 @@ yamlToMetaValue pMetaValue (YAML.Mapping _ _ o) =
152152 fmap MetaMap <$> yamlMap pMetaValue o
153153yamlToMetaValue _ _ = return $ return $ MetaString ""
154154
155−yamlMap :: PandocMonad m
156− => ParserT Text ParserState m (F MetaValue)
155+yamlMap :: (PandocMonad m, HasLastStrPosition st)
156+ => ParserT Text st m (Future st MetaValue)
157157 -> M.Map (YAML.Node YE.Pos) (YAML.Node YE.Pos)
158− -> ParserT Text ParserState m (F (M.Map Text MetaValue))
158+ -> ParserT Text st m (Future st (M.Map Text MetaValue))
159159yamlMap pMetaValue o = do
160160 kvs <- forM (M.toList o) $ \(key, v) -> do
161161 k <- maybe (throwError $ PandocParseError