Skip to main content

Module linebreaker

Module linebreaker 

Source
Expand description

MathML line-breaking algorithm.

Port of LaTeXML::Post::MathML::Linebreaker (1053 lines of Perl). Implements line-breaking for long Presentation MathML expressions by finding optimal breakpoints and inserting <mspace linebreak="newline"/>.

Strategy (from Perl source):

  1. If top-level has trailing punctuation, remove it to add back later
  2. Find all layouts that fit within a specified width (top-down)
    • Find possible breaks within current node
    • Recursively find possible layouts for children
    • Pattern of breaks depends on tag (sub/superscripts don’t break)
    • Each combination scored by width + penalty
  3. Apply the best layout’s breaks

Structs§

Layout
A single layout option for a MathML subtree.
Linebreaker
Line-breaking configuration.