internal IMathAtom AtomForCommand(string command, char stopChar)
        {
            var atom = MathAtoms.ForLatexSymbolName(command);

            if (atom is Accent accent)
            {
                accent.InnerList = BuildInternal(true);
                return(accent);
            }
            if (atom != null)
            {
                return(atom);
            }
            switch (command)
            {
            case "frac":
                return(new Fraction {
                    Numerator = BuildInternal(true),
                    Denominator = BuildInternal(true)
                });

            case "binom":
                return(new Fraction(false)
                {
                    Numerator = BuildInternal(true),
                    Denominator = BuildInternal(true),
                    LeftDelimiter = "(",
                    RightDelimiter = ")"
                });

            case "sqrt":
                var rad = new Radical();
                if (ExpectCharacter('['))
                {
                    rad.Degree   = BuildInternal(false, ']');
                    rad.Radicand = BuildInternal(true);
                }
                else
                {
                    rad.Radicand = BuildInternal(true);
                }
                return(rad);

            case "left":
                var oldInner = _currentInnerAtom;
                _currentInnerAtom = new Inner {
                    LeftBoundary = _BoundaryAtomForDelimiterType("left")
                };
                if (_currentInnerAtom.LeftBoundary == null)
                {
                    return(null);
                }
                _currentInnerAtom.InnerList = BuildInternal(false, stopChar);
                if (_currentInnerAtom.RightBoundary == null)
                {
                    SetError("Missing \\right");
                    return(null);
                }
                var newInner = _currentInnerAtom;
                _currentInnerAtom = oldInner;
                return(newInner);

            case "overline":
                return(new Overline {
                    InnerList = BuildInternal(true)
                });

            case "underline":
                return(new Underline()
                {
                    InnerList = BuildInternal(true)
                });

            case "begin":
                var env = ReadEnvironment();
                if (env == null)
                {
                    return(null);
                }
                var table = BuildTable(env, null, false, stopChar);
                return(table);

            case "color":
                return(new Color {
                    ColorString = ReadColor(),
                    InnerList = BuildInternal(true)
                });

            case "prime":
                SetError(@"\prime won't be supported as Unicode has no matching character. Use ' instead.");
                return(null);

            default:
                var extResult = Extension._MathListBuilder.AtomForCommand(this, command);
                if (extResult != null)
                {
                    return(extResult);
                }
                SetError("Invalid command \\" + command);
                return(null);
            }
        }
Beispiel #2
0
 public IMathAtom Visit(Radical target, bool finalize)
 => new Radical(target, finalize);
Beispiel #3
0
 public Radical(Radical cloneMe, bool finalize) : base(cloneMe, finalize)
 {
     Radicand = AtomCloner.Clone(cloneMe.Radicand, finalize);
     Degree   = AtomCloner.Clone(cloneMe.Degree, finalize);
 }