[go: up one dir, main page]

Module html

Module html 

Source
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’s Write interface.

Enums§

ChildRendering
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 the title 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, returning the concatenated literal contents of text, code and math blocks. Line breaks and soft breaks are represented as a single whitespace character.
collect_text_append
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.
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_plugins and 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, ```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.