Expand description
HTML renderering infrastructure for the CommonMark AST, as well as helper
functions. format_document
and format_document_with_plugins
use the standard formatter. The
create_formatter!
macro allows specialisation
of formatting for specific node types.
Structs§
- Context
- Context struct given to formatter functions as taken by
html::format_document_with_formatter
. Output can be appended to through this struct’sWrite
interface.
Enums§
- Child
Rendering - Returned by the
format_document_with_formatter
callback to indicate whether children of a node should be rendered with full HTML as usual, in “plain” mode, such as for thetitle
attribute of an image (which is a full subtree in CommonMark — there are probably few other use cases for “plain” mode), or whether they should be skipped.
Functions§
- collect_
text - Recurses through a node and all of its children in depth-first (document) order, appending the literal contents of text, code and math blocks to an output buffer. Line breaks and soft breaks are represented as a single whitespace character.
- escape
- Writes buffer to output, escaping anything that could be interpreted as an HTML tag.
- escape_
href - Writes buffer to output, escaping in a manner appropriate for URLs in HTML attributes.
- format_
document - Formats an AST as HTML, modified by the given options.
- format_
document_ with_ formatter - Formats the given AST with all options and formatter function specified.
- format_
document_ with_ plugins - Formats an AST as HTML, modified by the given options. Accepts custom plugins.
- format_
node_ default - Default node formatting function, used by
format_document
,format_document_with_plugins
and as the fallback for any node types not handled in custom formatters created bycreate_formatter!
. - render_
math - Renders a math dollar inline,
$...$
and$$...$$
using<span>
to be similar to other renderers. - render_
math_ code_ block - Renders a math code block,
```math
using<pre><code>
. - render_
sourcepos - Renders sourcepos data for the given node to the supplied
Context
. - write_
opening_ tag - Writes an opening HTML tag, using an iterator to enumerate the attributes. Note that attribute values are automatically escaped.