// Copyright 2017-2022 The MathJax Consortium // SPDX-License-Identifier: Apache-2.0 // Based on BaseMethods.Dots, BaseItems.DotsItem and MmlMo.texClass (MathJax 3.2.2).
package tex import // DotsItem keeps both candidates as properties, not stack children. Create // both now, including the unused one, in the original token-factory order. type pendingDots struct { ldots *mml.Node cdots *mml.Node } func ( *parser) () *pendingDots { := .token("mo", "\u2026") .Attributes.Set("stretchy", false) .applyVectorFactory() := .token("mo", "\u22EF") .Attributes.Set("stretchy", false) .applyVectorFactory() return &pendingDots{ldots: , cdots: } } func ( *pendingDots) () bool { return .ldots != nil } // A non-MML successor (including a row end) always selects lower dots. func ( *pendingDots) () []*mml.Node { if !.active() { return nil } := .ldots * = pendingDots{} return []*mml.Node{} } // Empty PushAll results leave DotsItem pending. An actual MML successor selects // the candidate, then is delivered unchanged after it. Groups and left/right // expressions arrive here only after their enclosing item has completed. func ( *pendingDots) ( []*mml.Node) []*mml.Node { if !.active() || len() == 0 { return } := .ldots if := dotsCoreMO([0]); != nil { := dotsOperatorClass() if == mml.TeXClassBin || == mml.TeXClassRel { = .cdots } } * = pendingDots{} return append([]*mml.Node{}, ...) } func dotsCoreMO( *mml.Node) *mml.Node { if == nil || !.Flags.Embellished { return nil } for .Kind != "mo" { := .Core() if == nil || == { return nil } = } return } // Before inheritance, a mo's cached Go class can be only its constructor's // provisional value. The primary getter instead honors an explicitly assigned // class or looks up the current forms, defaulting to REL without saving it. // Do not run operator inheritance here: it also changes attributes and spacing. func dotsOperatorClass( *mml.Node) mml.TeXClass { if , := .Property("texClass"); { return .TeXClass } := operatorForms() if .Attributes.IsSet("form") { , := .Attributes.Get("form") if , := .(string); { := []string{} for , := range { if != { = append(, ) } } = } } if , := lookupOperatorDefinition(textContent(), ); { return mml.TeXClass(.TexClass) } return mml.TeXClassRel }