Skip to main content

Module inline

Module inline 

Source
Expand description

The inline parser (M2 wave 2): a port of docutils states.py Inliner for emphasis/strong/literal recognition, escape semantics, and the problematic/unclosed machinery. References, roles, and footnote references extend this module in later wave-2 tasks.

Escape model (probe-verified): backslash escapes convert to a \x00 marker + char before recognition (escape2null); at Text emission the markers strip (\x00 and \x00\n remove BOTH chars, joining words; bare \x00 drops, keeping the escaped char). Inline literals restore backslashes instead. Behavior sources: the wave-2 probe notes (2026-08-07-m2-wave2-probes.md) and the differential fixture — never memory.

Structs§

InlineResult
Result of inline-parsing one text block: the paragraph/title children, plus system_messages the caller attaches AFTER the enclosing element.
RefContext
The slice of sphinx’s env.ref_context the inline roles read: the values OptionXRefRole/PyXRefRole stamp on their pending_xrefs, plus the key-existence flags AnyXRefRole.process_link’s blanket refnode.attributes.update(env.ref_context) (sphinx/roles.py) needs — a ref_context key can exist holding Python None (pformat’s "True" sentinel) or a list that the balanced directive nesting has drained back to [] (pformat "") by the time the doctree is serialized, so a bare Option<&str> cannot distinguish “absent” from those.

Functions§

escape2null
docutils utils.escape2null: every \ + char becomes \x00 + char; a trailing lone backslash becomes a bare \x00.
parse_inline
Inline-parse one logical text block (a paragraph’s joined lines, a title, a term…). lineno anchors any generated messages.
parse_inline_ext
unescape
docutils nodes.unescape: drop \x00 and \x00\n (both chars), then bare \x00 markers. With restore_backslashes every marker becomes a literal \ instead (inline literals).