// Copyright (c) 2019-2022 The MathJax Consortium // SPDX-License-Identifier: Apache-2.0 // Source: ts/input/tex/physics/{PhysicsMethods,PhysicsMappings}.ts.
package tex import func ( *parser) ( string) ([]*mml.Node, error) { // MatrixQuantity uses GetStar and GetNext's JavaScript whitespace rules. := .readMathtoolsStar() for .pos < len(.source) && internalTextSpace(.peekRune()) { .consumeRune() } := "array" if == "smqty" || == "smallmatrixquantity" { = "smallmatrix" } , , := "", "", "" var error := byte(0) if .pos < len(.source) { = .source[.pos] } switch { case '{': , _, = .readArgumentAtCursor(, false) case '(', '[', '|': .pos++ , = string(), string() if == '(' { = ")" if { , = "\\lgroup", "\\rgroup" } } else if == '[' { = "]" } := string() if == '(' { = ")" } else if == '[' { = "]" } , = .readUpTo(, ) default: // The fallback renders an empty fenced array without consuming the // next token. Only the GetNext whitespace has been consumed. , = "(", ")" } if != nil { return nil, } // In array the {} supplies the column definition; in smallmatrix it // remains a real empty group in the first cell. A fresh child parser // preserves both outcomes and the registered environment/fence commands. := "\\begin{" + + "}{} " + + "\\end{" + + "}" if != "" { = "\\left" + + + "\\right" + } , := .parseChild() if != nil { return nil, } return unwrapInferred(), nil }