Skip to main content

get_math

Function get_math 

Source
pub fn get_math(doc: &PostDocument) -> Option<Node>
Expand description

Extract the math subtree(s) from a post-processed document, mirroring Perl LaTeXML::Util::Pack::get_math (Pack.pm L247-280).

  • If exactly one <math> (or <Math>) is present, return it.
  • If multiple, return their least common ancestor by walking up from the first one until its descendant-count matches the document’s total. Unwraps trailing <tr> / <td> so the LCA isn’t a table cell.
  • If no math nodes at all, fall through to a math-image (<img class="ltx_Math">) XPath; if that’s also empty, fall through to get_embeddable so callers get a useful node either way.