math

package
v0.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 3, 2026 License: LGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteMathML

func WriteMathML(m *Math) ([]byte, error)

WriteMathML serializes m as W3C MathML 2.0 (PHP Writer\MathML).

func WriteOMML

func WriteOMML(m *Math) ([]byte, error)

WriteOMML serializes m as a display equation (m:oMathPara / m:oMath).

func WriteOMath added in v0.8.0

func WriteOMath(m *Math) ([]byte, error)

WriteOMath serializes m as an inline m:oMath (no oMathPara wrapper).

Types

type Delimiter added in v0.8.0

type Delimiter struct {
	Beg     string
	End     string
	Content Element
	// contains filtered or unexported fields
}

Delimiter is m:d (matched fences).

func NewDelimiter added in v0.8.0

func NewDelimiter(beg, end string, content Element) *Delimiter

type Element

type Element interface {
	// contains filtered or unexported methods
}

Element is a node in an Office Math expression tree.

type Fraction

type Fraction struct {
	Numerator   Element
	Denominator Element
	// contains filtered or unexported fields
}

Fraction is m:f (numerator / denominator).

func NewFraction

func NewFraction(num, den Element) *Fraction

type Group

type Group struct {
	Elements []Element
	// contains filtered or unexported fields
}

Group is a sequence of child elements.

func (*Group) Add

func (g *Group) Add(el Element) Element

Add appends a child and returns it.

func (*Group) Remove

func (g *Group) Remove(el Element)

Remove deletes the first occurrence of el (PHP AbstractGroupElement::remove).

type Identifier

type Identifier struct {
	Value string
	// contains filtered or unexported fields
}

Identifier is an OMML identifier (variable name).

func NewIdentifier

func NewIdentifier(v string) *Identifier

type Math

type Math struct {
	Group
}

Math is an Office Math container (PHPOffice Math\Math).

func New

func New() *Math

New returns an empty math expression.

func ParseLaTeX added in v0.8.0

func ParseLaTeX(src string) (*Math, error)

ParseLaTeX converts a basic TeX math string into an Office Math tree. Supported constructs: identifiers, numbers, operators, {groups}, \frac{a}{b}, \sqrt{x}, x^{n}, x_{n}, and a small set of named symbols.

func ReadMathML

func ReadMathML(r io.Reader) (*Math, error)

ReadMathML parses a MathML document into a Math tree (PHP Reader\MathML).

func ReadOMML

func ReadOMML(r io.Reader) (*Math, error)

ReadOMML parses an OMML fragment into a Math tree.

type Numeric

type Numeric struct {
	Value string
	// contains filtered or unexported fields
}

Numeric is a numeric literal.

func NewNumeric

func NewNumeric(v string) *Numeric

type Operator

type Operator struct {
	Value string
	// contains filtered or unexported fields
}

Operator is a math operator such as +, −, =.

func NewOperator

func NewOperator(v string) *Operator

type Radical added in v0.8.0

type Radical struct {
	Deg  Element
	Base Element
	// contains filtered or unexported fields
}

Radical is m:rad (square root).

func NewRadical added in v0.8.0

func NewRadical(base Element) *Radical

type Row

type Row struct {
	Group
}

Row is a horizontal group of elements.

func NewRow

func NewRow() *Row

type Semantics

type Semantics struct {
	Group
	Annotations map[string]string
}

Semantics wraps a MathML semantics node.

func NewSemantics

func NewSemantics() *Semantics

func (*Semantics) AddAnnotation

func (s *Semantics) AddAnnotation(encoding, annotation string) *Semantics

AddAnnotation stores a MathML annotation by encoding (PHP Semantics::addAnnotation).

func (*Semantics) Annotation

func (s *Semantics) Annotation(encoding string) string

Annotation returns the annotation for encoding, or "".

type Subscript added in v0.8.0

type Subscript struct {
	Base Element
	Sub  Element
	// contains filtered or unexported fields
}

Subscript is m:sSub.

func NewSubscript added in v0.8.0

func NewSubscript(base, sub Element) *Subscript

type Superscript

type Superscript struct {
	Base Element
	Sup  Element
	// contains filtered or unexported fields
}

Superscript is m:sSup.

func NewSuperscript

func NewSuperscript(base, sup Element) *Superscript

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL