sergiocorreia / panflute

An Pythonic alternative to John MacFarlane's pandocfilters, with extra helper functions
http://scorreia.com/software/panflute/
BSD 3-Clause "New" or "Revised" License
500 stars 59 forks source link

Support for Pandoc 3.2.x and Pandoc API 1.23.1 #248

Open mfhepp opened 4 months ago

mfhepp commented 4 months ago

Starting with Pandoc 3.1.6.1, the compatible version of the Pandoc API (on Hackage: pandoc-types has changed to 1.23.0.1 and later to 1.23.1 (latest).

It would be great if you (or somebody else via a PR) could update Panflute so that it becomes usable with Pandoc 3.2!

Your work is very much appreciated, btw!

As my small contribution: I looked into what changed in pandoc-types from 1.23.0: Besides updating the GHC, CI/CD components, and allowing bytestring 0.12, the only changes that may affect Panflute are IMHO these two:

https://github.com/jgm/pandoc-types/commit/1d0e8b2b3f373903280dc8d5c0f385ee6fce1a46

src/Text/Pandoc/JSON.hs

instance (Walkable [a] Pandoc, MonadIO m) => ToJSONFilter m (a -> [a]) where
  toJSONFilter f = liftIO $ BL.getContents >>=
    BL.putStr . encode . (walk (concatMap f) :: Pandoc -> Pandoc) .
    either error id .
    eitherDecode'

src/Text/Pandoc/JSON.hs

- instance (Walkable a Pandoc) => ToJSONFilter IO (a -> a) where
-  toJSONFilter f = BL.getContents >>=
+ instance (Walkable a Pandoc, MonadIO m) => ToJSONFilter m (a -> a) where
+  toJSONFilter f = liftIO $ BL.getContents >>=
+    BL.putStr . encode . (walk f :: Pandoc -> Pandoc) . either error id .
+    eitherDecode'

https://github.com/jgm/pandoc-types/commit/01b2b86c8b2002cba205eac87bcf8fc8c446ea22

The snippet from the changelog is below.

[1.23.1]

[1.23.0.1]