Skip to main content

compile_declare_pattern

Function compile_declare_pattern 

Source
pub fn compile_declare_pattern(body_text: &str) -> DeclarePattern
Expand description

Compile a \lxDeclare body_text into pattern metadata. Handles both wildcard and non-wildcard patterns.

Perl: compile_match1 digests tokens to DOM, then domToXPath. Rust: pattern-match on body_text string and generate broad XPath with Rust-side filtering criteria (avoids XPath nested predicate bug).

Font-awareness is deliberately NOT baked into these XPaths: the serialized @font attribute is only finalized after math parsing, so a rewrite-time @font='…' predicate matches nothing (and would silently break the wildcard/subscript/prime rewrites). Font discrimination happens Rust-side instead — declare_node_matches (rewrite path, via the resolved _font id) and apply_lx_declarations (post-rewrite fast path, via match_font).