示例#1
0
        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;
                }
            }
        }
示例#2
0
 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;
 }
示例#3
0
 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);
 }
示例#4
0
 public Underline(Underline cloneMe, bool finalize) : base(cloneMe, finalize)
 {
     this.InnerList = AtomCloner.Clone(cloneMe.InnerList, finalize);
 }
示例#5
0
 /// <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)))));
 }
示例#6
0
 public Accent(Accent cloneMe, bool finalize) : base(cloneMe, finalize)
 {
     InnerList = AtomCloner.Clone(cloneMe.InnerList, finalize);
 }
示例#7
0
 public Group(Group cloneMe, bool finalize) : base(cloneMe, finalize)
 {
     InnerList = AtomCloner.Clone(cloneMe.InnerList, finalize);
 }
示例#8
0
 public Radical(Radical cloneMe, bool finalize) : base(cloneMe, finalize)
 {
     Radicand = AtomCloner.Clone(cloneMe.Radicand, finalize);
     Degree   = AtomCloner.Clone(cloneMe.Degree, finalize);
 }
示例#9
0
 public Color(Color cloneMe, bool finalize) : base(cloneMe, finalize)
 {
     InnerList   = AtomCloner.Clone(cloneMe.InnerList, finalize);
     ColorString = cloneMe.ColorString;
 }