public MathList(IMathList cloneMe, bool finalize) : this() { if (!finalize) { foreach (var atom in cloneMe.Atoms) { var cloneAtom = AtomCloner.Clone(atom, finalize); Add(cloneAtom); } } else { IMathAtom prevNode = null; foreach (var atom in cloneMe.Atoms) { var newNode = AtomCloner.Clone(atom, finalize); if (atom.IndexRange == Range.Zero) { int prevIndex = prevNode is null ? 0 : prevNode.IndexRange.Location + prevNode.IndexRange.Length; newNode.IndexRange = new Range(prevIndex, 1); } switch (newNode.AtomType) { case MathAtomType.BinaryOperator: switch (prevNode?.AtomType) { case null: case MathAtomType.BinaryOperator: case MathAtomType.Relation: case MathAtomType.Open: case MathAtomType.Punctuation: case MathAtomType.LargeOperator: newNode.AtomType = MathAtomType.UnaryOperator; break; } break; case MathAtomType.Relation: case MathAtomType.Punctuation: case MathAtomType.Close: if (prevNode != null && prevNode.AtomType == MathAtomType.BinaryOperator) { prevNode.AtomType = MathAtomType.UnaryOperator; } break; case MathAtomType.Number: if (prevNode != null && prevNode.AtomType == MathAtomType.Number && prevNode.Subscript == null && prevNode.Superscript == null) { prevNode.Fuse(newNode); continue; // do not add the new node; we fused it instead. } break; } Add(newNode); prevNode = newNode; } } }
public Fraction(Fraction cloneMe, bool finalize) : base(cloneMe, finalize) { Numerator = AtomCloner.Clone(cloneMe.Numerator, finalize); Denominator = AtomCloner.Clone(cloneMe.Denominator, finalize); LeftDelimiter = cloneMe.LeftDelimiter; RightDelimiter = cloneMe.RightDelimiter; HasRule = cloneMe.HasRule; }
public static IMathAtom ForLatexSymbolName(string symbolName) { if (symbolName == null) { throw new ArgumentNullException(nameof(symbolName)); } if (Aliases.ContainsKey(symbolName)) { symbolName = Aliases[symbolName]; } if (Commands.TryGetByFirst(symbolName, out var symbol)) { return(AtomCloner.Clone(symbol, false)); } return(null); }
public Underline(Underline cloneMe, bool finalize) : base(cloneMe, finalize) { this.InnerList = AtomCloner.Clone(cloneMe.InnerList, finalize); }
/// <summary> /// Deep copy, finalized or not. /// </summary> public Table(Table cloneMe, bool finalize) : base(cloneMe, finalize) { InterColumnSpacing = cloneMe.InterColumnSpacing; InterRowAdditionalSpacing = cloneMe.InterRowAdditionalSpacing; Environment = cloneMe.Environment; Alignments = cloneMe.Alignments.ToList(); Cells = new List <List <IMathList> >(cloneMe.Cells.Select(list => new List <IMathList>(list.Select(sublist => AtomCloner.Clone(sublist, finalize))))); }
public Accent(Accent cloneMe, bool finalize) : base(cloneMe, finalize) { InnerList = AtomCloner.Clone(cloneMe.InnerList, finalize); }
public Group(Group cloneMe, bool finalize) : base(cloneMe, finalize) { InnerList = AtomCloner.Clone(cloneMe.InnerList, finalize); }
public Radical(Radical cloneMe, bool finalize) : base(cloneMe, finalize) { Radicand = AtomCloner.Clone(cloneMe.Radicand, finalize); Degree = AtomCloner.Clone(cloneMe.Degree, finalize); }
public Color(Color cloneMe, bool finalize) : base(cloneMe, finalize) { InnerList = AtomCloner.Clone(cloneMe.InnerList, finalize); ColorString = cloneMe.ColorString; }