pandoc-2.9.2.1: Conversion between markup formats

Copyright | Copyright (C) 2013-2020 John MacFarlane
License | GNU GPL, version 2 or above
Maintainer | John MacFarlane <jgm@berkeley.edu>
Stability | alpha
Portability | portable
Safe Haskell | None
Language | Haskell2010

Text.Pandoc.Writers.Shared

Description

Shared utility functions for pandoc writers.

Synopsis

- metaToContext :: (Monad m, TemplateTarget a) => WriterOptions -> ([Block] -> m (Doc a)) -> ([Inline] -> m (Doc a)) -> Meta -> m (Context a)
- metaToContext' :: (Monad m, TemplateTarget a) => ([Block] -> m (Doc a)) -> ([Inline] -> m (Doc a)) -> Meta -> m (Context a)
- addVariablesToContext :: TemplateTarget a => WriterOptions -> Context a -> Context a
- getField :: FromContext a b => Text -> Context a -> Maybe b
- setField :: ToContext a b => Text -> b -> Context a -> Context a
- resetField :: ToContext a b => Text -> b -> Context a -> Context a
- defField :: ToContext a b => Text -> b -> Context a -> Context a
- tagWithAttrs :: HasChars a => Text -> Attr -> Doc a
- isDisplayMath :: Inline -> Bool
- fixDisplayMath :: Block -> Block
- unsmartify :: WriterOptions -> Text -> Text
- gridTable :: (Monad m, HasChars a) => WriterOptions -> (WriterOptions -> [Block] -> m (Doc a)) -> Bool -> [Alignment] -> [Double] -> [[Block]] -> [[[Block]]] -> m (Doc a)
- lookupMetaBool :: Text -> Meta -> Bool
- lookupMetaBlocks :: Text -> Meta -> [Block]
- lookupMetaInlines :: Text -> Meta -> [Inline]
- lookupMetaString :: Text -> Meta -> Text
- stripLeadingTrailingSpace :: [Inline] -> [Inline]
- toSubscript :: Char -> Maybe Char
- toSuperscript :: Char -> Maybe Char
- toTableOfContents :: WriterOptions -> [Block] -> Block
- endsWithPlain :: [Block] -> Bool

# Documentation

metaToContext :: (Monad m, TemplateTarget a) => WriterOptions -> ([Block] -> m (Doc a)) -> ([Inline] -> m (Doc a)) -> Meta -> m (Context a) Source #

Create template Context from a `Meta` and an association list of variables, specified at the command line or in the writer. Variables overwrite metadata fields with the same names. If multiple variables are set with the same name, a list is assigned. Does nothing if `writerTemplate` is Nothing.

metaToContext' :: (Monad m, TemplateTarget a) => ([Block] -> m (Doc a)) -> ([Inline] -> m (Doc a)) -> Meta -> m (Context a) Source #

Like 'metaToContext, but does not include variables and is not sensitive to `writerTemplate`.

addVariablesToContext :: TemplateTarget a => WriterOptions -> Context a -> Context a Source #

Add variables to a template Context, using monoidal append. Also add `meta-json`. Note that metadata values are used in template contexts only when like-named variables aren't set.

getField :: FromContext a b => Text -> Context a -> Maybe b Source #

Retrieve a field value from a template context.

setField :: ToContext a b => Text -> b -> Context a -> Context a Source #

Set a field of a template context. If the field already has a value, convert it into a list with the new value appended to the old value(s). This is a utility function to be used in preparing template contexts.

resetField :: ToContext a b => Text -> b -> Context a -> Context a Source #

Reset a field of a template context. If the field already has a value, the new value replaces it. This is a utility function to be used in preparing template contexts.

defField :: ToContext a b => Text -> b -> Context a -> Context a Source #

Set a field of a template context if it currently has no value. If it has a value, do nothing. This is a utility function to be used in preparing template contexts.

tagWithAttrs :: HasChars a => Text -> Attr -> Doc a Source #

isDisplayMath :: Inline -> Bool Source #

fixDisplayMath :: Block -> Block Source #

unsmartify :: WriterOptions -> Text -> Text Source #

gridTable Source #

Arguments

:: (Monad m, HasChars a) |
=> WriterOptions |
-> (WriterOptions -> [Block] -> m (Doc a)) |
-> Bool | headless
-> [Alignment] |
-> [Double] |
-> [[Block]] |
-> [[[Block]]] |
-> m (Doc a) |

lookupMetaBool :: Text -> Meta -> Bool Source #

Retrieve the metadata value for a given `key` and convert to Bool.

lookupMetaBlocks :: Text -> Meta -> [Block] Source #

Retrieve the metadata value for a given `key` and extract blocks.

lookupMetaInlines :: Text -> Meta -> [Inline] Source #

Retrieve the metadata value for a given `key` and extract inlines.

lookupMetaString :: Text -> Meta -> Text Source #

Retrieve the metadata value for a given `key` and convert to String.

stripLeadingTrailingSpace :: [Inline] -> [Inline] Source #

toSubscript :: Char -> Maybe Char Source #

toSuperscript :: Char -> Maybe Char Source #

toTableOfContents :: WriterOptions -> [Block] -> Block Source #

Construct table of contents (as a bullet list) from document body.

endsWithPlain :: [Block] -> Bool Source #