Skip to main content

Module declare

Module declare 

Source
Expand description

The \lxDeclare pattern compiler and its paired structural matcher.

Perl keeps this machinery in Core/Rewrite.pm (domToXPath digests the declaration pattern and compiles an XPath with baked-in predicates); the Rust port instead recognizes the pattern SOURCE string (one arm per structural family), emits a deliberately BROAD XPath, and verifies each match Rust-side in declare_node_matches — sidestepping the nested XPath-predicate problems and the font-at-rewrite-time trap (see base_text_predicate). The compiler (compile_declare_pattern) and the matcher are a PAIRED construction: every DeclarePatternType variant has one arm in each, and both matches are exhaustive so adding a family breaks both at compile time (the same drift-protection principle as the fingerprint/estimate pair in digested.rs).

Structs§

DeclarePattern
Metadata for a compiled \lxDeclare pattern. Contains the XPath, pattern type for Rust-side filtering, and wildcard info.

Enums§

DeclarePatternType
Structural family of a compiled \lxDeclare pattern. One variant per compiler arm; consumed exhaustively by declare_node_matches.

Functions§

compile_declare_pattern
Compile a \lxDeclare body_text into pattern metadata. Handles both wildcard and non-wildcard patterns.
declare_node_matches
Rust-side filtering for \lxDeclare pattern matching. XPath matches are broad (to avoid nested predicate bugs); this function verifies the matched node’s children match the specific pattern.