private Atom AttachScripts(TexFormula formula, string value, ref int position, Atom atom) { SkipWhiteSpace(value, ref position); if (position == value.Length) { return(atom); } // Check for prime marks. var primesRowAtom = new RowAtom(); var i = position + 1; while (i < value.Length) { if (value[i] == primeChar) { primesRowAtom.Add(SymbolAtom.GetAtom("prime")); } else if (!IsWhiteSpace(value[i])) { break; } position++; i++; } // Attach prime marks as superscript, if any were found. if (primesRowAtom.Elements.Count > 0) { atom = new ScriptsAtom(atom, null, primesRowAtom); } TexFormula superscriptFormula = null; TexFormula subscriptFormula = null; var ch = value[position]; switch (ch) { case superScriptChar: // Attach superscript. position++; superscriptFormula = ReadScript(formula, value, ref position); SkipWhiteSpace(value, ref position); if (position < value.Length && value[position] == subScriptChar) { // Attach subscript also. position++; subscriptFormula = ReadScript(formula, value, ref position); } break; case subScriptChar: // Add subscript. position++; subscriptFormula = ReadScript(formula, value, ref position); SkipWhiteSpace(value, ref position); if (position < value.Length && value[position] == superScriptChar) { // Attach superscript also. position++; superscriptFormula = ReadScript(formula, value, ref position); } break; } if (superscriptFormula is null && subscriptFormula is null) { return(atom); } // Check whether to return Big Operator or Scripts. if (atom.GetRightType() == TexAtomType.BigOperator) { return(new BigOperatorAtom(atom, subscriptFormula?.RootAtom, superscriptFormula?.RootAtom)); } return(new ScriptsAtom(atom, subscriptFormula?.RootAtom, superscriptFormula?.RootAtom)); }
public override TexAtomType GetLeftType() => RowAtom.GetLeftType();
public override TexAtomType GetRightType() => RowAtom.GetRightType();
public StyledAtom(Atom atom, Brush backgroundColor, Brush foregroundColor) { RowAtom = new RowAtom(atom); Background = backgroundColor; Foreground = foregroundColor; }