Skip to main content

Module mathml

Module mathml 

Source
Expand description

MathML conversion processor.

Port of LaTeXML::Post::MathML (2162 lines) + submodules:

  • Presentation.pm (146 lines) — Presentation MathML rendering rules
  • Content.pm (31 lines) — Content MathML rendering rules
  • Linebreaker.pm (1053 lines) — MathML line-breaking algorithm
  • OperatorDictionary.pm (252 lines) — Operator symbol table

This is the primary math conversion format for web output. Converts XMath parsed math into Presentation MathML and/or Content MathML.

Modules§

content
Content MathML rendering rules.
linebreaker
MathML line-breaking algorithm.
operator_dictionary
MathML Operator Dictionary.
presentation
Presentation MathML rendering rules.

Structs§

MathML
MathML post-processor.
TextAttrs
Perl’s %attr for pmml_text_aux — the presentation attributes an enclosing ltx:* element contributes to the m:mtext elements below it.

Enums§

ApplyHandler
Presentation handler type for XMApp nodes.

Functions§

apply_handler_for_meaning
Determine the presentation handler for a specific meaning.
apply_handler_for_role
Determine the presentation handler for an XMApp based on operator role.
cmml_element_for_meaning
Known Content MathML elements for specific meanings.
convert_xm_text_content
Eagerly materialize an XMText-or-picture subtree into owned NodeData.
encoding_for_mimetype
MathML encoding names for parallel markup annotation-xml.
find_inherited_attribute
Find an inherited attribute by walking up the LaTeXML ancestor chain.
get_xm_hint_spacing
Convert an XMHint spacing attribute to em value.
has_dedicated_cmml_structure
Whether an XMApp with this meaning has a dedicated Content MathML structure.
is_bigop_role
Whether a role should use the “big operator” presentation style.
math_context_font
The font a formula’s tokens are read against: a font inside the formula (between the XMath and its ltx:Math), never the text around it. Perl’s pmml_top/cmml_top take find_inherited_attribute (MathML.pm:278, :1293), the enclosing text element’s font, which is right only while the tokens are written relative to that element; ours are written relative to the text default (document.rs finalize_rec), so a token without a font is upright serif whatever text surrounds the formula, and a sans or italic text font must not reach it (<mi> of \mathrm{c} in a theorem body, of + in \emph of a sans document). OXIDIZED_DESIGN_DIVERGENCES #780; witness 2608.14133.
pmml_parenthesize
Parenthesize an expression with open/close delimiters.
pmml_punctuate
Punctuate a list of items with separators.
pmml_row
Wrap items in an mrow, filtering out ignorable items.
pmml_tag_for_role
Presentation MathML tag for a token role.
pmml_text_aux
Convert a text node within XMText to Presentation MathML.
pmml_unrow
Unwrap an mrow if it has no attributes.
rebuild_text_subtree
Rebuild a libxml2 subtree into owned NodeData, dropping internal _*, xml:id, and fragid attributes. Shared between convert_xm_text_content (Perl convertXMTextContent, Post.pm L456-489) and pmml_text_aux for cases where Perl calls cloneNode($node, 'nest') (MathML.pm L1073) — i.e. when an unhandled element like ltx:ref appears inside a text-mode fragment and must survive into the output so the XSLT can transform it (e.g. ltx:ref → <a>).
rebuild_text_subtree_with_doc
Same as rebuild_text_subtree, but consults the post-document’s namespace map to resolve elements whose source xmlns="…" carries an empty prefix. add_nodes only emits elements whose tag is prefix:local; without a prefix the element is dropped with a malformed:namespace warning. libxml2 reports an empty Namespace::get_prefix() for the default-namespace branch even when the doc has a ltx: prefix declared elsewhere, so we reverse-lookup the URI in PostDocument::namespaces to recover the canonical prefix.
style_size
Size percentage for math styles.
style_step
Math style step-down table.