Skip to main content

Module content_parser

Module content_parser 

Source

Structs§

ParsedBlock
A parsed block (paragraph, heading, list item, code block)
ParsedImage
An inline image recovered by a parser, before it becomes an ImageAnchor.
ParsedInline
The three parallel things a block stores, as recovered from parsed spans.
ParsedSpan
A parsed inline span with formatting info.
ParsedTable
A parsed table extracted from markdown or HTML.
ParsedTableCell
A parsed table cell containing inline spans.

Enums§

ParsedElement
A parsed element: either a block or a table.

Constants§

HTML_FOOTNOTE_ATTR
The attribute an HTML producer uses to say “this element is a footnote reference”, and the label it names.
LINE_SEPARATOR
U+2028 LINE SEPARATOR: a line break inside a block, the one Shift+Enter makes in a word processor.
TABLE_ANCHOR
The U+FFFC OBJECT REPLACEMENT CHARACTER that stands for a table in the document’s text.

Functions§

character_format_from_span
Convert a ParsedSpan (parser output) into the CharacterFormat used by FormatRun. is_code_block forces monospace as the font family for every span inside a code block.
djot_to_plain_text
The prose of a Djot document, with no entities, no store, and no threads.
format_runs_from_spans
Translate a slice of parsed spans into (plain_text, format_runs).
html_line_ends_before
Whether a paragraph’s line ends before rest, the inline content after a run of its text: the ends_line of that run (see push_html_text). It does when nothing but empty content follows, or when the next text starts a line.
html_text_ends_open
Whether the text of a paragraph’s line, text added to what came before it on its line, ends in whitespace an HTML reader would collapse a space after it into: the after_space of the run after it (see push_html_text). after_space says the same of the text before text, and is the answer when text is empty.
parse_djot
Parse djot source into the shared ParsedElement intermediate, mirroring parse_markdown. Uses the jotdown pull parser.
parse_html
parse_html_elements
Read html into blocks and tables.
parse_markdown
Read markdown into blocks and tables.
push_html_text
Write text, a run of a paragraph’s text, into out as HTML: each of its lines (it separates them with LINE_SEPARATOR) escaped by escape, the lines joined by line_break, and a line whose whitespace an HTML reader would collapse put in a <span style="white-space: pre-wrap">, where browsers, Qt and this crate’s own HTML reader keep it as it is.
split_block_at_line_breaks
block as one block per line of its text, a line ending at each \n.
task_box_markdown
The box a Markdown task item writes after its list marker: [x] or [ ] , nothing for an item that is no task. Shared by the two Markdown writers.
task_checkbox_end_html
What closes task_checkbox_html’s label, after the item’s inline text.
task_checkbox_html
The checkbox an HTML list item opens with when it is a task, nothing otherwise, inside the <label> that names it: the item’s text, which task_checkbox_end_html closes the label after, is the checkbox’s accessible name (a bare checkbox reads as “checkbox, checked” and the text as another item). Written as well-formed XML (disabled="disabled", a closed tag) because the same markup is packaged into EPUB XHTML chapters, which a minimised attribute and an unclosed input would break in a strict reader. Shared by the two HTML writers; html_item_checkbox reads it back, through the label.