Module html
HTML rendering infrastructure for the CommonMark AST, as well as helper functions.
format_document and format_document_with_plugins use the standard
formatter. The [create_formatter!][super::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'sWriteinterface.
Enums
-
ChildRendering
Returned by the
format_document_with_formattercallback to indicate whether children of a node should be rendered with full HTML as usual, in "plain" mode, such as for thetitleattribute 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
- dangerous_url Check if the input would be considered a dangerous url
- 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_pluginsand as the fallback for any node types not handled in custom formatters created by [create_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,
```mathusing<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.