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§
- Inline
Result - 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_contextthe inline roles read: the valuesOptionXRefRole/PyXRefRolestamp on their pending_xrefs, plus the key-existence flagsAnyXRefRole.process_link’s blanketrefnode.attributes.update(env.ref_context)(sphinx/roles.py) needs — a ref_context key can exist holding PythonNone(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 bareOption<&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…).
linenoanchors any generated messages. - parse_
inline_ ext - unescape
- docutils
nodes.unescape: drop\x00and\x00\n(both chars), then bare\x00markers. Withrestore_backslashesevery marker becomes a literal\instead (inline literals).