| Maintainer | Brent Yorgey <byorgey@gmail.com> |
|---|---|
| Safe Haskell | None |
Text.BlogLiterately.Transform
Description
Tools for putting together a pipeline transforming the source for a post into a completely formatted HTML document.
- data Transform = Transform {
- getTransform :: BlogLiterately -> Kleisli IO Pandoc Pandoc
- xfCond :: BlogLiterately -> Bool
- runTransform :: Transform -> BlogLiterately -> Kleisli IO Pandoc Pandoc
- runTransforms :: [Transform] -> BlogLiterately -> Kleisli IO Pandoc Pandoc
- wptexifyXF :: Transform
- ghciXF :: Transform
- imagesXF :: Transform
- highlightXF :: Transform
- standardTransforms :: [Transform]
- centerImagesXF :: Transform
- xformDoc :: BlogLiterately -> [Transform] -> String -> IO String
- whenA :: Arrow a => a b b -> Bool -> a b b
- fixLineEndings :: String -> String
Transforms
A document transformation consists of two parts: an actual transformation, expressed as a function over Pandoc documents, and a condition specifying whether the transformation should actually be applied.
The transformation itself takes a BlogLiterately configuration
as an argument. You may of course ignore it if you do not need
to know anything about the configuration. The --xtra (or -x)
flag is also provided especially as a method of getting
information from the command-line to custom extensions. Arguments
passed via -x on the command line are available from the xtra
field of the BlogLiterately configuration.
The transformation is then specified as a arrow, which is isomorphic to Kleisli IO Pandoc
PandocPandoc -> IO Pandoc. If
you have a pure function of type Pandoc -> Pandoc, wrap it in a
call to arr to produce a Kleisli arrow. If you have a
function Pandoc -> IO Pandoc, wrap it in the Kleisli
constructor.
For examples, see the implementations of the standard transforms below.
Constructors
| Transform | |
Fields
| |
runTransform :: Transform -> BlogLiterately -> Kleisli IO Pandoc PandocSource
Run a Transform (if its condition is met).
runTransforms :: [Transform] -> BlogLiterately -> Kleisli IO Pandoc PandocSource
Run a pipeline of Transforms.
Standard transforms
These transforms are enabled by default in the standard BlogLiterately executable.
Format embedded LaTeX for WordPress (if the wplatex flag is set).
Upload embedded local images to the server (if the uploadImages
flag is set).
highlightXF :: TransformSource
Perform syntax highlighting on code blocks.
standardTransforms :: [Transform]Source
The standard set of transforms that are run by default:
wptexifyXF, ghciXF, imagesXF, highlightXF.
Other transforms
These transforms are not enabled by default. To use them, see Text.BlogLiterately.Run.
centerImagesXF :: TransformSource
Center any images which occur in a paragraph by themselves. Inline images are not affected.
Transforming documents
xformDoc :: BlogLiterately -> [Transform] -> String -> IO StringSource
Transform a complete input document string to an HTML output string, given a list of transformation passes.
Utilities
fixLineEndings :: String -> StringSource
Turn CRLF pairs into a single LF. This is necessary since
readMarkdown is picky about line endings.