Pretty.Renderer lets you specify custom rendering functions to modify the
output of the pretty printer as it is layed out. You do not need to use this
module for the default monochrome text only rendering which can be achieved
with Pretty.pretty.
If you have a tagged Doc model, you can use the tags to do syntax highlighting
with a custom Renderer. You can also turn the output into other structured
forms such as HTML.
A custom Renderer.
This works a bit like a foldl operation. Note that the text being rendered
is folded left to right, which means if you accumulate intermediate results into
Lists, you will need to reverse them.
The init value defines the initial state of an accumulator that is passed
over the entire rendering.
Tagged and untagged string from the Doc are passed through the tagged
and untagged functions. (DEPRECATED)
When the end of a line is reached, untagged is invoked to update the
accumulator. Note that you must manually add \n newline character here if
you need one. You may not be using newlines for an HTML rendering.
The outer function is invoked on the complete accumulator, and provides an
opportunity to complete the layout, for example by adding outer HTML tags
around in, and so on.
The open and close functions are passed through the tagged, openTag and
closeTag functions.
Pretty prints a document trying to fit it as best as possible to the specified column width of the page.
A custom
Renderermust be specified to handle the different parts of the output.