Skip to main content

Module html_block

Module html_block 

Source
Expand description

Shared HTML block-start classification.

A line whose first tag names one of these elements starts an HTML block in rumdl’s parser (lint_context::heading_detection::detect_html_blocks). Reflow consults the same predicate so a wrapped line can never introduce a construct the parser would classify differently: the two must agree, and sharing the list keeps them from drifting apart.

Constants§

BLOCK_ELEMENTS
HTML elements whose tags open an HTML block at line start (CommonMark type-1 and type-6 conditions, as recognized by rumdl’s parser).
NON_SPEC_BLOCK_ELEMENTS
The elements of BLOCK_ELEMENTS that CommonMark does not name in its type-1 or type-6 start conditions. A spec parser opens a block on one only through start condition 7, which parsers disagree on where a block may start: after a table row, markdown-rs ends the table there and pulldown-cmark reads the tag as the next row.
TYPE_1_BLOCK_ELEMENTS
Type-1 tags per CommonMark: blank lines inside these blocks do not terminate them — only a matching end tag (or EOF) does.

Functions§

complete_tag_len
The byte length of the complete HTML open tag or closing tag text starts with, as CommonMark defines one: <name, attributes each preceded by whitespace (with an unquoted, single-quoted or double-quoted value), then optional whitespace and > or />; or </name, optional whitespace and >. Only spaces and tabs count as whitespace, since the caller holds a single line.
opens_tag_line_html_block
Whether trimmed (a line with leading whitespace already stripped) opens an HTML block through CommonMark start condition 7: a complete open or closing tag of any element but the type-1 raw ones, followed by nothing but whitespace. Unlike every other HTML block such a line cannot interrupt a paragraph, so it matters only where a paragraph starts, and whether a line qualifies depends on all of its text, not on how it begins.
opens_untagged_html_block
Whether trimmed (a line with leading whitespace already stripped) opens an HTML block that no tag name identifies: a comment, a processing instruction, a declaration or a CDATA section (CommonMark start conditions 2 to 5). Each interrupts a paragraph like a block-level tag does, and none of them is a tag parse_html_block_start can name, so a caller asking “does this line start a block?” needs both.
parse_html_block_start
If trimmed (a line with leading whitespace already stripped) opens an HTML block per rumdl’s parser, return the lowercased tag name and whether it is a closing tag. Returns None for text, autolinks, and inline-level tags (<span>, <b>, …), which cannot interrupt a paragraph.