pandoc-utils-0.7.1: Utility functions to work with Pandoc in Haskell applications.
Safe HaskellNone
LanguageHaskell2010

Text.Pandoc.Utils

Description

This module exports all the utility functions provided by this package.

Synopsis

Filter utils (see Text.Pandoc.Filter.Utils)

class ToPartialFilter m f p where Source #

A helper typeclass used as a polymorphic constructor of PartialFilterM.

Methods

mkFilter Source #

Arguments

:: f

A filter function, usually a -> a for some Walkable a p.

-> PartialFilterM m p

Wrapped Pandoc filter.

The actual constructor of PartialFilterM. It takes an ordinary filter function a -> b and wraps it as a wrapped filter PartialFilterM. It can also be used to convert between different types of PartialFilterM m.

Instances

Instances details
(Monad m, Walkable a b) => ToPartialFilter m (PartialFilterM m a) b Source #

This instance can be used to convert PartialFilterM m a to PartialFilterM m b.

Instance details

Defined in Text.Pandoc.Filter.Utils

(Monad m, Walkable [a] p) => ToPartialFilter m (a -> m [a]) p Source # 
Instance details

Defined in Text.Pandoc.Filter.Utils

Methods

mkFilter :: (a -> m [a]) -> PartialFilterM m p Source #

(Monad m, Walkable [a] p) => ToPartialFilter m (a -> [a]) p Source # 
Instance details

Defined in Text.Pandoc.Filter.Utils

Methods

mkFilter :: (a -> [a]) -> PartialFilterM m p Source #

(Monad m, Walkable a p) => ToPartialFilter m (a -> m a) p Source # 
Instance details

Defined in Text.Pandoc.Filter.Utils

Methods

mkFilter :: (a -> m a) -> PartialFilterM m p Source #

(Monad m, Walkable a p) => ToPartialFilter m (a -> a) p Source # 
Instance details

Defined in Text.Pandoc.Filter.Utils

Methods

mkFilter :: (a -> a) -> PartialFilterM m p Source #

type PandocFilterM m = PartialFilterM m Pandoc Source #

An alias for PartialFilterM m Pandoc, a monadic version of PandocFilter.

  • m: a monad.

type PandocFilter = PartialFilter Pandoc Source #

An alias for PartialFilter Pandoc. It encapsulates a monadic filter Pandoc -> m Pandoc acting directly on Pandoc.

  • m: a monad.

type PartialFilter = PartialFilterM Identity Source #

PartialFilter p is a wrapper for ordinary p -> p Pandoc filters acting on a subnode (e.g. Inline or Block) of the Pandoc abstract syntax tree. On this page, we will call it a "wrapped" filter to distinguish it from filter functions a -> b.

data PartialFilterM m p Source #

PartialFilterM m p is a wrapper for any monadic p -> m p Pandoc filters acting on a subnode (e.g. Inline or Block) of the Pandoc abstract syntax tree. On this page, we will call it a "wrapped" filter to distinguish it from filter functions a -> m b.

  • m: a monad.
  • p: the type of a subnode of Pandoc (e.g. Inline).

Instances

Instances details
(Monad m, Walkable a b) => ToPartialFilter m (PartialFilterM m a) b Source #

This instance can be used to convert PartialFilterM m a to PartialFilterM m b.

Instance details

Defined in Text.Pandoc.Filter.Utils

Monad m => Semigroup (PartialFilterM m p) Source #

The Semigroup instance of PartialFilterM. f1 <> f2 will apply f1 first followed by f2.

Instance details

Defined in Text.Pandoc.Filter.Utils

Monad m => Monoid (PartialFilterM m p) Source #

The Monoid instance of PartialFilterM.

Instance details

Defined in Text.Pandoc.Filter.Utils

applyFilter Source #

Arguments

:: PartialFilter p

A wrapped filter.

-> p

Pandoc AST node.

-> p

Transformed node.

Apply a wrapped filter to p, which returns p directly.

getFilterM Source #

Arguments

:: (Monad m, Walkable a b) 
=> PartialFilterM m a

A wrapped filter on a.

-> b -> m b

Filter function that can be directly applied to b.

It is mostly the same as applyFilterM, which converts a wrapped monadic filter to a monadic filter function, but it should be used when you don't need to apply the filter immediately. There is a slight difference in that it will perform an implicit conversion if the requested filter function is of a different type.

For example, it can be used to convert a wrapped monadic filter PartialFilterM IO Inline to monadic filter function Block -> IO Block.

getFilter Source #

Arguments

:: Walkable a b 
=> PartialFilter a

A wrapped partial filter on a.

-> b -> b

Filter function that can be directly applied to b.

It is mostly the same as applyFilter, which converts a wrapped filter to a filter function, but it should be used when you don't need to apply the filter immediately. There is a slight difference in that it will perform an implicit conversion if the requested filter function is of a different type.

For example, it can be used to convert a wrapped filter PartialFilter Inline to filter function Block -> Block.

mkConcatedFilter Source #

Arguments

:: (Monad m, ToPartialFilter m f p, Foldable t) 
=> t f

A list of filter functions of the same type.

-> PartialFilterM m p

Concatenated filter.

Construct a wrapped filter PartialFilterM from a list of filter functions of the same type. The final filter is concatenated from left to right such that the first element in the list will be applied first and the last element will be applied at the end.

For example, it can be used to convert an list of filter functions [Inline -> [Inline]] to a wrapped filter PandocFilter.

toFilterM Source #

Arguments

:: Monad m 
=> PartialFilter p

An ordinary filter.

-> PartialFilterM m p

The monadic version.

Convert an ordinary wrapped filter PartialFilter to the monadic version PartialFilterM.

For example, it can be used to convert an ordinary wrapped filter PartialFilter Inline to monadic wrapped filter PartialFilterM IO Inline.

sequenceFiltersM Source #

Arguments

:: (Foldable t, Monad m) 
=> t (PartialFilterM m p)

A list of monadic wrapped filters.

-> p

Pandoc AST node.

-> m p

Transformed node.

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.

sequenceFilters Source #

Arguments

:: Foldable t 
=> t (PartialFilter p)

A list of wrapped filter.

-> p

Pandoc AST node.

-> p

Transformed node.

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.

getConcatedFilterM Source #

Arguments

:: (Foldable t, Monad m, Walkable a b) 
=> t (PartialFilterM m a)

A list of monadic partial filters on a.

-> b -> m b

Monadic filter function applicable to b directly.

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 don't need to apply the filter immediately. There is a slight difference in that it will perform an implicit conversion if the requested filter function is of a different type.

For example, it can be used to convert a list of wrapped monadic filter [PartialFilterM IO Inline] to a filter function Block -> IO Block.

getConcatedFilter Source #

Arguments

:: (Foldable t, Walkable a b) 
=> t (PartialFilter a)

A list of wrapped filter acting on a

-> b -> b

Filter function applicable to b directly.

It is mostly the same as applyFilters, which converts a list of wrapped filter to a filter function, but it should be used when you don't need to apply the filter immediately. There is a slight difference in that it will perform an implicit conversion if the requested filter function is of a different type.

For example, it can be used to convert a list of wrapped filter [PartialFilter Inline] to a filter function Block -> Block.

convertFilterM Source #

Arguments

:: (Monad m, ToPartialFilter m f p) 
=> f

A monadic filter function.

-> p -> m p

Monadic filter function acting on p.

Conversion between monadic filter functions, e.g. from Inline -> IO [Inline] filter to Pandoc -> IO Pandoc filter.

convertFilter Source #

Arguments

:: ToPartialFilter Identity f p 
=> f

A filter function.

-> p -> p

Filter function acting on p.

Conversion between filter functions, e.g. from Inline -> [Inline] filter to Pandoc -> Pandoc filter.

Attribute builders

String conversions