NativeElixirPdfUtilities.Validators.MathOperatorValidator (native_elixir_pdf_utilities v1.1.0)
View SourcePrepares operator semantics and Chromium-compatible authored MathML lengths.
The source is the 24 June 2025 MathML Core snapshot, sections 3.2.4.1, 3.2.4.2 and B.1. Invalid authored attribute syntax uses Core's dictionary fallback. Invalid API arguments and exceeded resource limits return diagnostics. This module does not render MathML or select stretch glyphs.
Summary
Types
Validated operator properties for a prepared MathML core operator.
Point lengths, glyph-height percentages, or the unbounded Core maximum.
Functions
Prepares the dictionary and authored properties of an mo core operator.
Types
@type semantics() :: %{ text: String.t(), form: :infix | :prefix | :postfix, explicit_form: boolean(), category: atom(), lspace: number(), rspace: number(), stretchy: boolean(), symmetric: boolean(), fence: boolean(), separator: boolean(), largeop: boolean(), movablelimits: boolean(), minsize: size_constraint(), maxsize: size_constraint(), stretch_axis: :horizontal | :vertical, single_character: boolean(), invisible: boolean() }
Validated operator properties for a prepared MathML core operator.
Point lengths, glyph-height percentages, or the unbounded Core maximum.
Functions
@spec prepare(term(), term(), term()) :: {:ok, semantics()} | {:error, {atom(), NativeElixirPdfUtilities.Diagnostics.diagnostic()}}
Prepares the dictionary and authored properties of an mo core operator.
attributes is a map of binary attribute names and values. text is preserved
exactly, including invisible operators, combining overlays and ASCII pairs.
The caller supplies the already prepared token text, without further cleanup.
context describes the outer embellished operator, not an inner wrapper:
parentis the MathML parent tag name, ornilfor a detached operator. Use:groupingfor prepared unknown MathML elements or anonymous rows.indexandcountdescribe in-flow siblings excluding space-like children. They default to zero and one. Empty sibling lists use index zero/count zero.child_indexis the index amongst all in-flow siblings and defaults toindex. It determines postfix form for a script child that is not the base.font_sizedefaults to 12 points;root_font_sizedefaults tofont_size. These sizes belong to the core operator. Optionalx_heightsupplies the selected core font's x-height in points forexlengths.cap_height,zero_advanceandline_heightsupply the selected-font cap height, zero advance and computed line height forcap,chandlhlengths.text_onlydefaults to true. Set false when the core contains element children, so it cannot use the text-keyed dictionary or single-glyph layout.
Spacing is returned in points. Percentage spacing uses the dictionary spacing
as its base. Percentage min/max sizes remain tagged until natural glyph height
is available. These are parsed constraints, not stretch targets. Negative
constraints are valid Core values. Follow-up stretch preparation in the math
validator must resolve percentages and clamp min/max against natural glyph
height; consumers must not independently reinterpret these constraints.
Fence and separator are semantic metadata and do not change Core geometry.
Numeric percentages and absolute, em, rem, ex, cap, ch and lh lengths are resolved
against the core operator's selected font and computed style.
Authored MathML length attributes using calc, min, max, or clamp
use the dictionary fallback, matching Chromium's ParseMathLength rejection
of calculated values. Ordinary CSS calculations are unaffected.
Optional viewport_width and
viewport_height are point dimensions of the actual CSS viewport. Root font
units use the corresponding root_* metric. Missing geometry is diagnosed.
stretch_axis uses the names accepted by MathLayout.stretch/6, even when
stretchy is false. Multi-character operators need text layout, not stretch/6.