summaryrefslogtreecommitdiff
path: root/src/Text/Pandoc.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Text/Pandoc.hs')
-rw-r--r--src/Text/Pandoc.hs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/Text/Pandoc.hs b/src/Text/Pandoc.hs
index ba05589cd..0cd1af099 100644
--- a/src/Text/Pandoc.hs
+++ b/src/Text/Pandoc.hs
@@ -247,3 +247,13 @@ instance (Data a) => ToJsonFilter (a -> a) where
instance (Data a) => ToJsonFilter (a -> IO a) where
toJsonFilter f = getContents >>= (bottomUpM f :: Pandoc -> IO Pandoc) . decodeJSON
>>= putStr . encodeJSON
+
+instance (Data a) => ToJsonFilter (a -> [a]) where
+ toJsonFilter f = getContents
+ >>= putStr . encodeJSON . (bottomUp (concatMap f) :: Pandoc -> Pandoc) . decodeJSON
+
+instance (Data a) => ToJsonFilter (a -> IO [a]) where
+ toJsonFilter f = getContents
+ >>= (bottomUpM (fmap concat . mapM f) :: Pandoc -> IO Pandoc) . decodeJSON
+ >>= putStr . encodeJSON
+