Skip to main content

convert_xm_text_content

Function convert_xm_text_content 

Source
pub fn convert_xm_text_content(
    doc: &PostDocument,
    node: &Node,
    convert_spaces: bool,
) -> Vec<NodeData>
Expand description

Eagerly materialize an XMText-or-picture subtree into owned NodeData.

Port of LaTeXML::Post::MathProcessor::convertXMTextContent (Post.pm L456-489). Walks node recursively and rebuilds the subtree as owned NodeData, so downstream consumers do not depend on the source node’s libxml2 lifetime. Internal _* attributes and stray xml:id are dropped (Perl mirrors this); fragid would be remapped to a fresh id in Perl but MathML::Presentation does not carry a processor-level id suffix through this path, so we drop it too and let the surrounding MathML ids govern.

When convert_spaces is true, leading/trailing whitespace on text nodes is replaced with NBSP so the rendered MathML does not collapse the space. A nested ltx:Math (a $...$ inside a text box that itself sits in math) is CONVERTED to presentation MathML by rebuild_text_subtree_with_doc rather than cloned raw — see the reentrancy note there (arXiv html_feedback #6847); Perl leaves it raw and warns unexpected:nested-math, which renders operator-first (garbled).