// Copyright 2017-2022 The MathJax Consortium // SPDX-License-Identifier: Apache-2.0 // Source: BaseMethods.Entry/Cr/CrLaTeX, BaseItems.CellItem, and StackItem.
package tex import // A cell is a closing stack item, not a space or a pre-parsed row boundary. // It can be replayed after Over/Style or a completed single Braket before it // reaches the actual open owner. CrLaTeX's spaces are delivered afterward. type cellItem struct { name string cr bool linebreak bool spacing string font string emptyFont bool color string envSaved bool // Cases.Entry observes this before pushing the closing CellItem. numCasesText bool } func ( *parser) ( string) error { := &cellItem{name: "\\" + , cr: true, linebreak: != "cr"} if == "\\" { // CrLaTeX tests raw characters here, without GetNext's whitespace. if .pos < len(.source) && .source[.pos] == '*' { .pos++ } if .pos < len(.source) && .source[.pos] == '[' { , , := .readBrackets(nil) if != nil { if , := .(*Error); && .ID == "MissingCloseBracket" { return texError(.ID, "Could not find closing ']' for argument to %s", .name) } return } if != "" { := dimensionFull.FindStringSubmatch() if == nil { return texError("BracketMustBeDimension", "Bracket argument to %s must be a dimension", .name) } .spacing = dimensionValue() } } } .commandCell = return nil } func ( *cellItem) () error { return texError("Misplaced", "Misplaced %s", .name) } func ( *cellItem) ( *parser) { if !.envSaved { .font, .emptyFont, .color = .activeFont, .fontExplicitEmpty, .activeColor .envSaved = true } } func ( *cellItem) () []*mml.Node { var []*mml.Node if .spacing != "" { = append(, setAttributes(node("mspace"), map[string]any{"depth": .spacing})) } return append(, setAttributes(node("mspace"), map[string]any{"linebreak": "newline"})) }