Text.Pandoc.Lua.Marshal.Filter

pandoc-lua-marshal-0.2.6: Use pandoc types in Lua

Copyright | © 2021-2024 Albert Krewinkel
License | MIT
Maintainer | Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
Safe Haskell | None
Language | Haskell2010

Text.Pandoc.Lua.Marshal.Filter

Contents

- Filters
- Individual filter functions
- Names in filter functions

Description

Marshaling/unmarshaling functions Lua filters, i.e., tables containing functions to be called on specific elements.

Synopsis

- data Filter = Filter {
  - filterWalkingOrder :: WalkingOrder
  - filterMap :: Map Name FilterFunction
  }
- data WalkingOrder
  - = WalkForEachType
  - | WalkTopdown
- peekFilter :: LuaError e => Peeker e Filter
- lookup :: Name -> Filter -> Maybe FilterFunction
- member :: Name -> Filter -> Bool
- newtype FilterFunction = FilterFunction Reference
- peekFilterFunction :: Peeker e FilterFunction
- pushFilterFunction :: LuaError e => FilterFunction -> LuaE e ()
- getFunctionFor :: Data a => Filter -> a -> Maybe FilterFunction
- baseFunctionName :: Data a => Proxy a -> Name
- listFunctionName :: Data a => Proxy a -> Name
- valueFunctionNames :: Data a => Proxy a -> [Name]

# Filters

data Filter #

Collection of filter functions (at most one function per element constructor)

Constructors

Filter |
Fields filterWalkingOrder :: WalkingOrder filterMap :: Map Name FilterFunction

data WalkingOrder #

Description of how an AST should be traversed.

Constructors

WalkForEachType | Process each type separately, traversing the tree bottom-up (leaves to root) for each type.
WalkTopdown | Traverse the tree top-down, from root to leaves and depth first, in a single traversal.

peekFilter :: LuaError e => Peeker e Filter #

Retrieves a default `Filter` object from the stack, suitable for filtering a full document.

lookup :: Name -> Filter -> Maybe FilterFunction #

Looks up a filter function in a Lua `Filter`.

member :: Name -> Filter -> Bool #

Checks whether the `Filter` contains a function of the given name.

# Individual filter functions

newtype FilterFunction #

Filter function stored in the registry

Constructors

FilterFunction Reference |

peekFilterFunction :: Peeker e FilterFunction #

Retrieves a filter function from the stack.

The value at the given index must be a function. It is stored in the Lua registry.

pushFilterFunction :: LuaError e => FilterFunction -> LuaE e () #

Pushes a filter function to the stack.

Filter functions are stored in the registry and retrieved from there.

getFunctionFor :: Data a => Filter -> a -> Maybe FilterFunction #

Finds the best filter function for a given element; returns `Nothing` if no such function exists.

# Names in filter functions

baseFunctionName :: Data a => Proxy a -> Name #

The name of a type's base function, which is called if there is no more specific function for a value.

listFunctionName :: Data a => Proxy a -> Name #

The name of the functions that's called on lists of the given type.

valueFunctionNames :: Data a => Proxy a -> [Name] #

Filter function names for a given type.