Macros allow users to access more advanced functionality from within Markdown syntax. There are two types
of macros, block and inline, which allow substitution of Block
and Inline
data, respectively. Macros
are called in a very similar fashion to shell programs: the argument string is split on whitespace. The
first word is the name of the macro, and the remaining words are the arguments. Option-parsing libraries
may be useful for interpreting the arguments.
Note: using blockMacros
and inlineMacros
at the same time with the same magic string and can lead to behavior
that depends on the order in which they are called, if any of the macro names are the same for block and inline
macros. However, if none of the macro names are the same, unrecognized macro names will be ignored by the pass
that doesn't recognize them, leaving them available to be recognized by the other pass.
- blockMacros :: Yesod master => String -> Map String ([String] -> GHandler sub master Block) -> Pandoc -> GHandler sub master Pandoc
- inlineMacros :: Yesod master => String -> Map String ([String] -> GHandler sub master Inline) -> Pandoc -> GHandler sub master Pandoc
- hamletToBlock :: Hamlet (Route master) -> GHandler sub master Block
- hamletToInline :: Hamlet (Route master) -> GHandler sub master Inline
Documentation
:: Yesod master | |
=> String | Magic string to introduce the macro |
-> Map String ([String] -> GHandler sub master Block) | Lookup table from macro names to macro functions |
-> Pandoc | |
-> GHandler sub master Pandoc |
Convert block-level macros. Block-level macros are signalled by a first-level header containing a piece of
inline code starting with a client-specified magic string. For example, if the magic string is ??
, a macro
can be called by
#`??MACRO_NAME MACRO_ARGS`
where MACRO_NAME
is the identifying name of the macro and MACRO_ARGS
is a space-separated list of arguments.
:: Yesod master | |
=> String | Magic string to introduce the macro |
-> Map String ([String] -> GHandler sub master Inline) | Lookup table from macro names to macro functions |
-> Pandoc | |
-> GHandler sub master Pandoc |
Convert block-level macros. Inline-level macros are signalled by a piece of inline code starting with a
client-specified magic string. For example, if the magic string is ??
, a macro can be called by
`??MACRO_NAME MACRO_ARGS`
where MACRO_NAME
is the identifying name of the macro and MACRO_ARGS
is a space-separated list of arguments.