pandoc-utils 0.5.1 → 0.6.0
raw patch · 5 files changed
+50/−15 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Text.Pandoc.Filter.Utils: seqFilters :: Foldable t => t (PartialFilter p) -> p -> p
+ Text.Pandoc.Filter.Utils: seqFiltersM :: (Foldable t, Monad m) => t (PartialFilterM m p) -> p -> m p
+ Text.Pandoc.Utils: applyFilter :: PartialFilter p -> p -> p
+ Text.Pandoc.Utils: class ToPartialFilter m f p
+ Text.Pandoc.Utils: convertFilter :: ToPartialFilter Identity f p => f -> p -> p
+ Text.Pandoc.Utils: convertFilterM :: (Monad m, ToPartialFilter m f p) => f -> p -> m p
+ Text.Pandoc.Utils: data PartialFilterM m p
+ Text.Pandoc.Utils: getConcatedFilter :: (Foldable t, Walkable a b) => t (PartialFilter a) -> b -> b
+ Text.Pandoc.Utils: getConcatedFilterM :: (Foldable t, Monad m, Walkable a b) => t (PartialFilterM m a) -> b -> m b
+ Text.Pandoc.Utils: getFilter :: Walkable a b => PartialFilter a -> b -> b
+ Text.Pandoc.Utils: getFilterM :: (Monad m, Walkable a b) => PartialFilterM m a -> b -> m b
+ Text.Pandoc.Utils: mkConcatedFilter :: (Monad m, ToPartialFilter m f p, Foldable t) => t f -> PartialFilterM m p
+ Text.Pandoc.Utils: mkFilter :: ToPartialFilter m f p => f -> PartialFilterM m p
+ Text.Pandoc.Utils: seqFilters :: Foldable t => t (PartialFilter p) -> p -> p
+ Text.Pandoc.Utils: seqFiltersM :: (Foldable t, Monad m) => t (PartialFilterM m p) -> p -> m p
+ Text.Pandoc.Utils: toFilterM :: Monad m => PartialFilter p -> PartialFilterM m p
+ Text.Pandoc.Utils: type PandocFilter = PartialFilter Pandoc
+ Text.Pandoc.Utils: type PandocFilterM m = PartialFilterM m Pandoc
+ Text.Pandoc.Utils: type PartialFilter = PartialFilterM Identity
Files
- CHANGELOG.md +5/−0
- pandoc-utils.cabal +1/−1
- src/Text/Pandoc/Filter/Utils.hs +36/−6
- src/Text/Pandoc/Utils.hs +1/−1
- test/Spec.hs +7/−7
CHANGELOG.md view
@@ -1,5 +1,10 @@ # Releases +## pandoc-utils 0.6.0 (2020-5-24)++- Rename `applyFilters` to `seqFilters` to avoid name conflicts with Pandoc+- `applyFilters` is now deprecated+ ## pandoc-utils 0.5.1 (2020-5-24) - Fix the link to Hakyll in package description.
pandoc-utils.cabal view
@@ -2,7 +2,7 @@ cabal-version: 2.0 name: pandoc-utils-version: 0.5.1+version: 0.6.0 synopsis: Utility functions to work with Pandoc in Haskell applications. description:
src/Text/Pandoc/Filter/Utils.hs view
@@ -27,9 +27,9 @@ mkConcatedFilter, -- * Wrapped filter application/composition applyFilter,- applyFilters,+ seqFilters, applyFilterM,- applyFiltersM,+ seqFiltersM, -- * Wrapped filter → filter function getFilter, getConcatedFilter,@@ -37,6 +37,9 @@ getConcatedFilterM, -- * Wrapped filter conversion toFilterM,+ -- * Deprecated+ applyFilters,+ applyFiltersM, ) where import Control.Monad ((>=>))@@ -177,22 +180,22 @@ -- | Apply a list of monadic wrapped filters sequentially, from left to right, -- i.e. the first element in the list will be applied first and the last -- element will be applied at the end.-applyFiltersM+seqFiltersM :: (Foldable t, Monad m) => t (PartialFilterM m p) -- ^ A list of monadic wrapped filters. -> p -- ^ 'Pandoc' AST node. -> m p -- ^ Transformed node.-applyFiltersM = applyFilterM . fold+seqFiltersM = applyFilterM . fold -- | Apply a list of wrapped filters sequentially, from left to right, i.e. -- the first element in the list will be applied first and the last element -- will be applied at the end.-applyFilters+seqFilters :: (Foldable t) => t (PartialFilter p) -- ^ A list of wrapped filter. -> p -- ^ 'Pandoc' AST node. -> p -- ^ Transformed node.-applyFilters = applyFilter . fold+seqFilters = applyFilter . fold -- | It is mostly the same as 'applyFiltersM', which converts a list of wrapped -- monadic filter to a monadic filter function, but it should be used when you@@ -238,3 +241,30 @@ => f -- ^ A filter function. -> (p -> p) -- ^ Filter function acting on @p@. convertFilter = applyFilter . mkFilter++-----------------+-- deprecated+-----------------++-- | Apply a list of monadic wrapped filters sequentially, from left to right,+-- i.e. the first element in the list will be applied first and the last+-- element will be applied at the end.+{-# DEPRECATED applyFiltersM "Use 'seqFiltersM' instead." #-}+applyFiltersM+ :: (Foldable t, Monad m)+ => t (PartialFilterM m p) -- ^ A list of monadic wrapped filters.+ -> p -- ^ 'Pandoc' AST node.+ -> m p -- ^ Transformed node.+applyFiltersM = seqFiltersM+++-- | Apply a list of wrapped filters sequentially, from left to right, i.e.+-- the first element in the list will be applied first and the last element+-- will be applied at the end.+{-# DEPRECATED applyFilters "Use 'seqFilters' instead. This function will conflict with a function with the same name in Pandoc." #-}+applyFilters+ :: (Foldable t)+ => t (PartialFilter p) -- ^ A list of wrapped filter.+ -> p -- ^ 'Pandoc' AST node.+ -> p -- ^ Transformed node.+applyFilters = seqFilters
src/Text/Pandoc/Utils.hs view
@@ -8,6 +8,6 @@ module Text.Pandoc.Utils.String ) where -import Text.Pandoc.Filter.Utils+import Text.Pandoc.Filter.Utils hiding (applyFilters, applyFiltersM) import Text.Pandoc.Filter.Utils.AttrBuilder import Text.Pandoc.Utils.String
test/Spec.hs view
@@ -174,7 +174,7 @@ -> Either P.PandocError Text -- ^ Html string or error mdToHtml md = P.runPure $ do doc <- P.readMarkdown def md- let doc' = applyFilters [beheadFilter, delinkFilter] doc+ let doc' = seqFilters [beheadFilter, delinkFilter] doc P.writeHtml5String def doc' mdToHtmlCompose@@ -334,7 +334,7 @@ it "applys merge correctly" $ applyFilter merge compPara2 `shouldBe` expectedMerge - describe "applyFilters" $ do+ describe "seqFilters" $ do it "applys PartialFilter composition from left to right" $ do applyFilter (dup <> merge) compPara `shouldBe` expectedDupMerge applyFilter (merge <> dup) compPara `shouldBe` expectedMergeDup@@ -350,15 +350,15 @@ describe "monoid instance" $ do it "applys PartialFilter composition from left to right" $ do- applyFilters [dup, merge] compPara `shouldBe` expectedDupMerge- applyFilters [merge, dup] compPara `shouldBe` expectedMergeDup+ seqFilters [dup, merge] compPara `shouldBe` expectedDupMerge+ seqFilters [merge, dup] compPara `shouldBe` expectedMergeDup it "applys PartialFilterM composition from left to right" $ do- let (doc, s) = runWriter $ applyFiltersM [extract, toFilterM dup] compPara+ let (doc, s) = runWriter $ seqFiltersM [extract, toFilterM dup] compPara doc `shouldBe` expectedDup s `shouldBe` T.pack "abcd" - let (doc', s') = runWriter $ applyFiltersM [toFilterM dup, extract] compPara+ let (doc', s') = runWriter $ seqFiltersM [toFilterM dup, extract] compPara doc' `shouldBe` expectedDup s' `shouldBe` T.pack "abcdabcd" @@ -397,7 +397,7 @@ readmeSpec = parallel $ describe "readme example" $ do it "processes filter examples correctly on AST level" $ do- applyFilters [beheadFilter, delinkFilter] readmeDoc `shouldBe` expectedDoc+ seqFilters [beheadFilter, delinkFilter] readmeDoc `shouldBe` expectedDoc applyFilter myFilter readmeDoc `shouldBe` expectedDoc (delinkPandoc . beheadPandoc) readmeDoc `shouldBe` expectedDoc