pandoc-types-1.23.1: Types for representing a structured document

Copyright | Copyright (C) 2013-2023 John MacFarlane
License | BSD3
Maintainer | John MacFarlane <jgm@berkeley.edu>
Stability | alpha
Portability | portable
Safe Haskell | Safe-Inferred
Language | Haskell2010

Text.Pandoc.Walk

Description

Functions for manipulating `Pandoc` documents or extracting information from them by walking the `Pandoc` structure (or intermediate structures like '[Block]' or '[Inline]'. These are faster (by a factor of four or five) than the generic functions defined in `Text.Pandoc.Generic`.

Here's a simple example, defining a function that replaces all the level 3+ headers in a document with regular paragraphs in ALL CAPS:

    import Text.Pandoc.Definition
    import Text.Pandoc.Walk
    import Data.Char (toUpper)

    modHeader :: Block -> Block
    modHeader (Header n _ xs) | n >= 3 = Para $ walk allCaps xs
    modHeader x = x

    allCaps :: Inline -> Inline
    allCaps (Str xs) = Str $ map toUpper xs
    allCaps x = x

    changeHeaders :: Pandoc -> Pandoc
    changeHeaders = walk modHeader

`query` can be used, for example, to compile a list of URLs linked to in a document:

    extractURL :: Inline -> [Text]
    extractURL (Link _ _ (u,_)) = [u]
    extractURL (Image _ _ (u,_)) = [u]
    extractURL _ = []

    extractURLs :: Pandoc -> [Text]
    extractURLs = query extractURL

Synopsis

- class Walkable a b where
  - walk :: (a -> a) -> b -> b
  - walkM :: (Monad m, Applicative m, Functor m) => (a -> m a) -> b -> m b
  - query :: Monoid c => (a -> c) -> b -> c
- queryBlock :: (Walkable a Citation, Walkable a [Block], Walkable a Row, Walkable a Caption, Walkable a TableHead, Walkable a TableBody, Walkable a TableFoot, Walkable a [Inline], Monoid c) => (a -> c) -> Block -> c
- queryCaption :: (Walkable a [Block], Walkable a [Inline], Walkable a ShortCaption, Monoid c) => (a -> c) -> Caption -> c
- queryRow :: (Walkable a Cell, Monoid c) => (a -> c) -> Row -> c
- queryTableHead :: (Walkable a Row, Monoid c) => (a -> c) -> TableHead -> c
- queryTableBody :: (Walkable a Row, Monoid c) => (a -> c) -> TableBody -> c
- queryTableFoot :: (Walkable a Row, Monoid c) => (a -> c) -> TableFoot -> c
- queryCell :: (Walkable a [Block], Monoid c) => (a -> c) -> Cell -> c
- queryCitation :: (Walkable a [Inline], Monoid c) => (a -> c) -> Citation -> c
- queryInline :: (Walkable a Citation, Walkable a [Block], Walkable a [Inline], Monoid c) => (a -> c) -> Inline -> c
- queryMetaValue :: (Walkable a MetaValue, Walkable a [Block], Walkable a [Inline], Monoid c) => (a -> c) -> MetaValue -> c
- queryMetaValue' :: Monoid c => (MetaValue -> c) -> MetaValue -> c
- queryPandoc :: (Walkable a Meta, Walkable a [Block], Monoid c) => (a -> c) -> Pandoc -> c
- walkBlockM :: (Walkable a [Block], Walkable a [Inline], Walkable a Row, Walkable a Caption, Walkable a TableHead, Walkable a TableBody, Walkable a TableFoot, Monad m, Applicative m, Functor m) => (a -> m a) -> Block -> m Block
- walkCaptionM :: (Walkable a [Block], Walkable a [Inline], Monad m, Walkable a ShortCaption) => (a -> m a) -> Caption -> m Caption
- walkRowM :: (Walkable a Cell, Monad m) => (a -> m a) -> Row -> m Row
- walkTableHeadM :: (Walkable a Row, Monad m) => (a -> m a) -> TableHead -> m TableHead
- walkTableBodyM :: (Walkable a Row, Monad m) => (a -> m a) -> TableBody -> m TableBody
- walkTableFootM :: (Walkable a Row, Monad m) => (a -> m a) -> TableFoot -> m TableFoot
- walkCellM :: (Walkable a [Block], Monad m) => (a -> m a) -> Cell -> m Cell
- walkCitationM :: (Walkable a [Inline], Monad m, Applicative m, Functor m) => (a -> m a) -> Citation -> m Citation
- walkInlineM :: (Walkable a Citation, Walkable a [Block], Walkable a [Inline], Monad m, Applicative m, Functor m) => (a -> m a) -> Inline -> m Inline
- walkMetaValueM :: (Walkable a MetaValue, Walkable a [Block], Walkable a [Inline], Monad f, Applicative f, Functor f) => (a -> f a) -> MetaValue -> f MetaValue
- walkMetaValueM' :: (Monad f, Applicative f, Functor f) => (MetaValue -> f MetaValue) -> MetaValue -> f MetaValue
- walkPandocM :: (Walkable a Meta, Walkable a [Block], Monad m, Applicative m, Functor m) => (a -> m a) -> Pandoc -> m Pandoc

# Documentation

class Walkable a b where #

Minimal complete definition

walkM, query

Methods

walk :: (a -> a) -> b -> b #

`walk f x` walks the structure `x` (bottom up) and replaces every occurrence of an `a` with the result of applying `f` to it.

walkM :: (Monad m, Applicative m, Functor m) => (a -> m a) -> b -> m b #

A monadic version of `walk`.

query :: Monoid c => (a -> c) -> b -> c #

`query f x` walks the structure `x` (bottom up) and applies `f` to every `a`, appending the results.

#### Instances

Instances details

Walkable Block Block # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: (Block -> Block) -> Block -> Block # walkM :: (Monad m, Applicative m, Functor m) => (Block -> m Block) -> Block -> m Block # query :: Monoid c => (Block -> c) -> Block -> c #
Walkable Block Caption # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: (Block -> Block) -> Caption -> Caption # walkM :: (Monad m, Applicative m, Functor m) => (Block -> m Block) -> Caption -> m Caption # query :: Monoid c => (Block -> c) -> Caption -> c #
Walkable Block Cell # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: (Block -> Block) -> Cell -> Cell # walkM :: (Monad m, Applicative m, Functor m) => (Block -> m Block) -> Cell -> m Cell # query :: Monoid c => (Block -> c) -> Cell -> c #
Walkable Block Citation # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: (Block -> Block) -> Citation -> Citation # walkM :: (Monad m, Applicative m, Functor m) => (Block -> m Block) -> Citation -> m Citation # query :: Monoid c => (Block -> c) -> Citation -> c #
Walkable Block Inline # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: (Block -> Block) -> Inline -> Inline # walkM :: (Monad m, Applicative m, Functor m) => (Block -> m Block) -> Inline -> m Inline # query :: Monoid c => (Block -> c) -> Inline -> c #
Walkable Block Meta # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: (Block -> Block) -> Meta -> Meta # walkM :: (Monad m, Applicative m, Functor m) => (Block -> m Block) -> Meta -> m Meta # query :: Monoid c => (Block -> c) -> Meta -> c #
Walkable Block MetaValue # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: (Block -> Block) -> MetaValue -> MetaValue # walkM :: (Monad m, Applicative m, Functor m) => (Block -> m Block) -> MetaValue -> m MetaValue # query :: Monoid c => (Block -> c) -> MetaValue -> c #
Walkable Block Pandoc # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: (Block -> Block) -> Pandoc -> Pandoc # walkM :: (Monad m, Applicative m, Functor m) => (Block -> m Block) -> Pandoc -> m Pandoc # query :: Monoid c => (Block -> c) -> Pandoc -> c #
Walkable Block Row # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: (Block -> Block) -> Row -> Row # walkM :: (Monad m, Applicative m, Functor m) => (Block -> m Block) -> Row -> m Row # query :: Monoid c => (Block -> c) -> Row -> c #
Walkable Block TableBody # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: (Block -> Block) -> TableBody -> TableBody # walkM :: (Monad m, Applicative m, Functor m) => (Block -> m Block) -> TableBody -> m TableBody # query :: Monoid c => (Block -> c) -> TableBody -> c #
Walkable Block TableFoot # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: (Block -> Block) -> TableFoot -> TableFoot # walkM :: (Monad m, Applicative m, Functor m) => (Block -> m Block) -> TableFoot -> m TableFoot # query :: Monoid c => (Block -> c) -> TableFoot -> c #
Walkable Block TableHead # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: (Block -> Block) -> TableHead -> TableHead # walkM :: (Monad m, Applicative m, Functor m) => (Block -> m Block) -> TableHead -> m TableHead # query :: Monoid c => (Block -> c) -> TableHead -> c #
Walkable Inline Block # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: (Inline -> Inline) -> Block -> Block # walkM :: (Monad m, Applicative m, Functor m) => (Inline -> m Inline) -> Block -> m Block # query :: Monoid c => (Inline -> c) -> Block -> c #
Walkable Inline Caption # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: (Inline -> Inline) -> Caption -> Caption # walkM :: (Monad m, Applicative m, Functor m) => (Inline -> m Inline) -> Caption -> m Caption # query :: Monoid c => (Inline -> c) -> Caption -> c #
Walkable Inline Cell # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: (Inline -> Inline) -> Cell -> Cell # walkM :: (Monad m, Applicative m, Functor m) => (Inline -> m Inline) -> Cell -> m Cell # query :: Monoid c => (Inline -> c) -> Cell -> c #
Walkable Inline Citation # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: (Inline -> Inline) -> Citation -> Citation # walkM :: (Monad m, Applicative m, Functor m) => (Inline -> m Inline) -> Citation -> m Citation # query :: Monoid c => (Inline -> c) -> Citation -> c #
Walkable Inline Inline # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: (Inline -> Inline) -> Inline -> Inline # walkM :: (Monad m, Applicative m, Functor m) => (Inline -> m Inline) -> Inline -> m Inline # query :: Monoid c => (Inline -> c) -> Inline -> c #
Walkable Inline Meta # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: (Inline -> Inline) -> Meta -> Meta # walkM :: (Monad m, Applicative m, Functor m) => (Inline -> m Inline) -> Meta -> m Meta # query :: Monoid c => (Inline -> c) -> Meta -> c #
Walkable Inline MetaValue # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: (Inline -> Inline) -> MetaValue -> MetaValue # walkM :: (Monad m, Applicative m, Functor m) => (Inline -> m Inline) -> MetaValue -> m MetaValue # query :: Monoid c => (Inline -> c) -> MetaValue -> c #
Walkable Inline Pandoc # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: (Inline -> Inline) -> Pandoc -> Pandoc # walkM :: (Monad m, Applicative m, Functor m) => (Inline -> m Inline) -> Pandoc -> m Pandoc # query :: Monoid c => (Inline -> c) -> Pandoc -> c #
Walkable Inline Row # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: (Inline -> Inline) -> Row -> Row # walkM :: (Monad m, Applicative m, Functor m) => (Inline -> m Inline) -> Row -> m Row # query :: Monoid c => (Inline -> c) -> Row -> c #
Walkable Inline TableBody # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: (Inline -> Inline) -> TableBody -> TableBody # walkM :: (Monad m, Applicative m, Functor m) => (Inline -> m Inline) -> TableBody -> m TableBody # query :: Monoid c => (Inline -> c) -> TableBody -> c #
Walkable Inline TableFoot # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: (Inline -> Inline) -> TableFoot -> TableFoot # walkM :: (Monad m, Applicative m, Functor m) => (Inline -> m Inline) -> TableFoot -> m TableFoot # query :: Monoid c => (Inline -> c) -> TableFoot -> c #
Walkable Inline TableHead # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: (Inline -> Inline) -> TableHead -> TableHead # walkM :: (Monad m, Applicative m, Functor m) => (Inline -> m Inline) -> TableHead -> m TableHead # query :: Monoid c => (Inline -> c) -> TableHead -> c #
Walkable Meta Meta # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: (Meta -> Meta) -> Meta -> Meta # walkM :: (Monad m, Applicative m, Functor m) => (Meta -> m Meta) -> Meta -> m Meta # query :: Monoid c => (Meta -> c) -> Meta -> c #
Walkable Meta Pandoc # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: (Meta -> Meta) -> Pandoc -> Pandoc # walkM :: (Monad m, Applicative m, Functor m) => (Meta -> m Meta) -> Pandoc -> m Pandoc # query :: Monoid c => (Meta -> c) -> Pandoc -> c #
Walkable MetaValue Meta # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: (MetaValue -> MetaValue) -> Meta -> Meta # walkM :: (Monad m, Applicative m, Functor m) => (MetaValue -> m MetaValue) -> Meta -> m Meta # query :: Monoid c => (MetaValue -> c) -> Meta -> c #
Walkable MetaValue MetaValue # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: (MetaValue -> MetaValue) -> MetaValue -> MetaValue # walkM :: (Monad m, Applicative m, Functor m) => (MetaValue -> m MetaValue) -> MetaValue -> m MetaValue # query :: Monoid c => (MetaValue -> c) -> MetaValue -> c #
Walkable MetaValue Pandoc # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: (MetaValue -> MetaValue) -> Pandoc -> Pandoc # walkM :: (Monad m, Applicative m, Functor m) => (MetaValue -> m MetaValue) -> Pandoc -> m Pandoc # query :: Monoid c => (MetaValue -> c) -> Pandoc -> c #
Walkable Pandoc Pandoc # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: (Pandoc -> Pandoc) -> Pandoc -> Pandoc # walkM :: (Monad m, Applicative m, Functor m) => (Pandoc -> m Pandoc) -> Pandoc -> m Pandoc # query :: Monoid c => (Pandoc -> c) -> Pandoc -> c #
(Foldable t, Traversable t, Walkable a b) => Walkable a (t b) # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: (a -> a) -> t b -> t b # walkM :: (Monad m, Applicative m, Functor m) => (a -> m a) -> t b -> m (t b) # query :: Monoid c => (a -> c) -> t b -> c #
(Walkable a b, Walkable a c) => Walkable a (b, c) # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: (a -> a) -> (b, c) -> (b, c) # walkM :: (Monad m, Applicative m, Functor m) => (a -> m a) -> (b, c) -> m (b, c) # query :: Monoid c0 => (a -> c0) -> (b, c) -> c0 #
Walkable [Block] Block # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: ([Block] -> [Block]) -> Block -> Block # walkM :: (Monad m, Applicative m, Functor m) => ([Block] -> m [Block]) -> Block -> m Block # query :: Monoid c => ([Block] -> c) -> Block -> c #
Walkable [Block] Caption # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: ([Block] -> [Block]) -> Caption -> Caption # walkM :: (Monad m, Applicative m, Functor m) => ([Block] -> m [Block]) -> Caption -> m Caption # query :: Monoid c => ([Block] -> c) -> Caption -> c #
Walkable [Block] Cell # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: ([Block] -> [Block]) -> Cell -> Cell # walkM :: (Monad m, Applicative m, Functor m) => ([Block] -> m [Block]) -> Cell -> m Cell # query :: Monoid c => ([Block] -> c) -> Cell -> c #
Walkable [Block] Citation # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: ([Block] -> [Block]) -> Citation -> Citation # walkM :: (Monad m, Applicative m, Functor m) => ([Block] -> m [Block]) -> Citation -> m Citation # query :: Monoid c => ([Block] -> c) -> Citation -> c #
Walkable [Block] Inline # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: ([Block] -> [Block]) -> Inline -> Inline # walkM :: (Monad m, Applicative m, Functor m) => ([Block] -> m [Block]) -> Inline -> m Inline # query :: Monoid c => ([Block] -> c) -> Inline -> c #
Walkable [Block] Meta # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: ([Block] -> [Block]) -> Meta -> Meta # walkM :: (Monad m, Applicative m, Functor m) => ([Block] -> m [Block]) -> Meta -> m Meta # query :: Monoid c => ([Block] -> c) -> Meta -> c #
Walkable [Block] MetaValue # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: ([Block] -> [Block]) -> MetaValue -> MetaValue # walkM :: (Monad m, Applicative m, Functor m) => ([Block] -> m [Block]) -> MetaValue -> m MetaValue # query :: Monoid c => ([Block] -> c) -> MetaValue -> c #
Walkable [Block] Pandoc # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: ([Block] -> [Block]) -> Pandoc -> Pandoc # walkM :: (Monad m, Applicative m, Functor m) => ([Block] -> m [Block]) -> Pandoc -> m Pandoc # query :: Monoid c => ([Block] -> c) -> Pandoc -> c #
Walkable [Block] Row # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: ([Block] -> [Block]) -> Row -> Row # walkM :: (Monad m, Applicative m, Functor m) => ([Block] -> m [Block]) -> Row -> m Row # query :: Monoid c => ([Block] -> c) -> Row -> c #
Walkable [Block] TableBody # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: ([Block] -> [Block]) -> TableBody -> TableBody # walkM :: (Monad m, Applicative m, Functor m) => ([Block] -> m [Block]) -> TableBody -> m TableBody # query :: Monoid c => ([Block] -> c) -> TableBody -> c #
Walkable [Block] TableFoot # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: ([Block] -> [Block]) -> TableFoot -> TableFoot # walkM :: (Monad m, Applicative m, Functor m) => ([Block] -> m [Block]) -> TableFoot -> m TableFoot # query :: Monoid c => ([Block] -> c) -> TableFoot -> c #
Walkable [Block] TableHead # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: ([Block] -> [Block]) -> TableHead -> TableHead # walkM :: (Monad m, Applicative m, Functor m) => ([Block] -> m [Block]) -> TableHead -> m TableHead # query :: Monoid c => ([Block] -> c) -> TableHead -> c #
Walkable [Inline] Block # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: ([Inline] -> [Inline]) -> Block -> Block # walkM :: (Monad m, Applicative m, Functor m) => ([Inline] -> m [Inline]) -> Block -> m Block # query :: Monoid c => ([Inline] -> c) -> Block -> c #
Walkable [Inline] Caption # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: ([Inline] -> [Inline]) -> Caption -> Caption # walkM :: (Monad m, Applicative m, Functor m) => ([Inline] -> m [Inline]) -> Caption -> m Caption # query :: Monoid c => ([Inline] -> c) -> Caption -> c #
Walkable [Inline] Cell # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: ([Inline] -> [Inline]) -> Cell -> Cell # walkM :: (Monad m, Applicative m, Functor m) => ([Inline] -> m [Inline]) -> Cell -> m Cell # query :: Monoid c => ([Inline] -> c) -> Cell -> c #
Walkable [Inline] Citation # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: ([Inline] -> [Inline]) -> Citation -> Citation # walkM :: (Monad m, Applicative m, Functor m) => ([Inline] -> m [Inline]) -> Citation -> m Citation # query :: Monoid c => ([Inline] -> c) -> Citation -> c #
Walkable [Inline] Inline # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: ([Inline] -> [Inline]) -> Inline -> Inline # walkM :: (Monad m, Applicative m, Functor m) => ([Inline] -> m [Inline]) -> Inline -> m Inline # query :: Monoid c => ([Inline] -> c) -> Inline -> c #
Walkable [Inline] Meta # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: ([Inline] -> [Inline]) -> Meta -> Meta # walkM :: (Monad m, Applicative m, Functor m) => ([Inline] -> m [Inline]) -> Meta -> m Meta # query :: Monoid c => ([Inline] -> c) -> Meta -> c #
Walkable [Inline] MetaValue # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: ([Inline] -> [Inline]) -> MetaValue -> MetaValue # walkM :: (Monad m, Applicative m, Functor m) => ([Inline] -> m [Inline]) -> MetaValue -> m MetaValue # query :: Monoid c => ([Inline] -> c) -> MetaValue -> c #
Walkable [Inline] Pandoc # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: ([Inline] -> [Inline]) -> Pandoc -> Pandoc # walkM :: (Monad m, Applicative m, Functor m) => ([Inline] -> m [Inline]) -> Pandoc -> m Pandoc # query :: Monoid c => ([Inline] -> c) -> Pandoc -> c #
Walkable [Inline] Row # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: ([Inline] -> [Inline]) -> Row -> Row # walkM :: (Monad m, Applicative m, Functor m) => ([Inline] -> m [Inline]) -> Row -> m Row # query :: Monoid c => ([Inline] -> c) -> Row -> c #
Walkable [Inline] TableBody # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: ([Inline] -> [Inline]) -> TableBody -> TableBody # walkM :: (Monad m, Applicative m, Functor m) => ([Inline] -> m [Inline]) -> TableBody -> m TableBody # query :: Monoid c => ([Inline] -> c) -> TableBody -> c #
Walkable [Inline] TableFoot # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: ([Inline] -> [Inline]) -> TableFoot -> TableFoot # walkM :: (Monad m, Applicative m, Functor m) => ([Inline] -> m [Inline]) -> TableFoot -> m TableFoot # query :: Monoid c => ([Inline] -> c) -> TableFoot -> c #
Walkable [Inline] TableHead # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: ([Inline] -> [Inline]) -> TableHead -> TableHead # walkM :: (Monad m, Applicative m, Functor m) => ([Inline] -> m [Inline]) -> TableHead -> m TableHead # query :: Monoid c => ([Inline] -> c) -> TableHead -> c #
Walkable [Block] [Block] # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: ([Block] -> [Block]) -> [Block] -> [Block] # walkM :: (Monad m, Applicative m, Functor m) => ([Block] -> m [Block]) -> [Block] -> m [Block] # query :: Monoid c => ([Block] -> c) -> [Block] -> c #
Walkable [Inline] [Inline] # |
Instance details Defined in Text.Pandoc.Walk Methods walk :: ([Inline] -> [Inline]) -> [Inline] -> [Inline] # walkM :: (Monad m, Applicative m, Functor m) => ([Inline] -> m [Inline]) -> [Inline] -> m [Inline] # query :: Monoid c => ([Inline] -> c) -> [Inline] -> c #

queryBlock :: (Walkable a Citation, Walkable a [Block], Walkable a Row, Walkable a Caption, Walkable a TableHead, Walkable a TableBody, Walkable a TableFoot, Walkable a [Inline], Monoid c) => (a -> c) -> Block -> c #

Perform a query on elements nested below a ``Block`` element by querying all directly nested lists of `Inline`s or `Block`s.

queryCaption :: (Walkable a [Block], Walkable a [Inline], Walkable a ShortCaption, Monoid c) => (a -> c) -> Caption -> c #

Query the elements below a `Cell` element.

queryRow :: (Walkable a Cell, Monoid c) => (a -> c) -> Row -> c #

Query the elements below a `Row` element.

queryTableHead :: (Walkable a Row, Monoid c) => (a -> c) -> TableHead -> c #

Query the elements below a `TableHead` element.

queryTableBody :: (Walkable a Row, Monoid c) => (a -> c) -> TableBody -> c #

Query the elements below a `TableBody` element.

queryTableFoot :: (Walkable a Row, Monoid c) => (a -> c) -> TableFoot -> c #

Query the elements below a `TableFoot` element.

queryCell :: (Walkable a [Block], Monoid c) => (a -> c) -> Cell -> c #

Query the elements below a `Cell` element.

queryCitation :: (Walkable a [Inline], Monoid c) => (a -> c) -> Citation -> c #

Perform a query on elements nested below a ``Citation`` element by querying the prefix and postfix `Inline` lists.

queryInline :: (Walkable a Citation, Walkable a [Block], Walkable a [Inline], Monoid c) => (a -> c) -> Inline -> c #

Perform a query on elements nested below an ``Inline`` element by querying nested lists of `Inline`s, `Block`s, or `Citation`s.

queryMetaValue :: (Walkable a MetaValue, Walkable a [Block], Walkable a [Inline], Monoid c) => (a -> c) -> MetaValue -> c #

Perform a query on elements nested below a ``MetaValue`` element by querying all directly nested lists of `Inline`s, list of `Block`s, or lists or maps of `MetaValue`s.

queryMetaValue' :: Monoid c => (MetaValue -> c) -> MetaValue -> c #

Perform a query on ``MetaValue`` elements nested below a ``MetaValue`` element

queryPandoc :: (Walkable a Meta, Walkable a [Block], Monoid c) => (a -> c) -> Pandoc -> c #

Query a pandoc element by recursing first into its ``Meta`` data and then append the result of recursing into the list of ``Block``s.

walkBlockM :: (Walkable a [Block], Walkable a [Inline], Walkable a Row, Walkable a Caption, Walkable a TableHead, Walkable a TableBody, Walkable a TableFoot, Monad m, Applicative m, Functor m) => (a -> m a) -> Block -> m Block #

Helper method to walk to elements nested below ``Block`` nodes.

When walking a block with this function, only the contents of the traversed block element may change. The element itself, i.e. its constructor, its ``Attr``, and its raw text value, will remain unchanged.

walkCaptionM :: (Walkable a [Block], Walkable a [Inline], Monad m, Walkable a ShortCaption) => (a -> m a) -> Caption -> m Caption #

Helper method to walk the elements nested below `Caption` nodes.

walkRowM :: (Walkable a Cell, Monad m) => (a -> m a) -> Row -> m Row #

Helper method to walk the elements nested below ``Row`` nodes. The ``Attr`` component is not changed by this operation.

walkTableHeadM :: (Walkable a Row, Monad m) => (a -> m a) -> TableHead -> m TableHead #

Helper method to walk the elements nested below ``TableHead`` nodes. The ``Attr`` component is not changed by this operation.

walkTableBodyM :: (Walkable a Row, Monad m) => (a -> m a) -> TableBody -> m TableBody #

Helper method to walk the elements nested below ``TableBody`` nodes. The ``Attr`` and ``RowHeadColumns`` components are not changed by this operation.

walkTableFootM :: (Walkable a Row, Monad m) => (a -> m a) -> TableFoot -> m TableFoot #

Helper method to walk the elements nested below ``TableFoot`` nodes. The ``Attr`` component is not changed by this operation.

walkCellM :: (Walkable a [Block], Monad m) => (a -> m a) -> Cell -> m Cell #

Helper method to walk the elements nested below `Cell` nodes. Only the `[`Block`]` cell content is changed by this operation.

walkCitationM :: (Walkable a [Inline], Monad m, Applicative m, Functor m) => (a -> m a) -> Citation -> m Citation #

Helper method to walk to elements nested below ``Citation`` nodes.

The non-inline contents of a citation will remain unchanged during traversal. Only the inline contents, viz. the citation's prefix and postfix, will be traversed further and can thus be changed during this operation.

walkInlineM :: (Walkable a Citation, Walkable a [Block], Walkable a [Inline], Monad m, Applicative m, Functor m) => (a -> m a) -> Inline -> m Inline #

Helper method to walk to elements nested below ``Inline`` nodes.

When walking an inline with this function, only the contents of the traversed inline element may change. The element itself, i.e. its constructor, cannot be changed.

walkMetaValueM :: (Walkable a MetaValue, Walkable a [Block], Walkable a [Inline], Monad f, Applicative f, Functor f) => (a -> f a) -> MetaValue -> f MetaValue #

Helper method to walk to elements nested below ``MetaValue`` nodes.

When walking a meta value with this function, only the contents of the traversed meta value element may change. `MetaBool` and `MetaString` will always remain unchanged.

walkMetaValueM' :: (Monad f, Applicative f, Functor f) => (MetaValue -> f MetaValue) -> MetaValue -> f MetaValue #

Helper method to walk ``MetaValue`` nodes nested below ``MetaValue`` nodes.

walkPandocM :: (Walkable a Meta, Walkable a [Block], Monad m, Applicative m, Functor m) => (a -> m a) -> Pandoc -> m Pandoc #

Helper method to walk the components of a Pandoc element.