Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions CSharpMath.Core.Tests/Atom/LaTeXParserTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public static Action<MathAtom> CheckAtom<T>
[InlineData(@"\pi+\theta\geq 3", new[] { typeof(Variable), typeof(BinaryOperator), typeof(Variable), typeof(Relation), typeof(Number) }, @"\pi +\theta \geq 3")]
// aliases
[InlineData(@"\pi\ne 5 \land 3", new[] { typeof(Variable), typeof(Relation), typeof(Number), typeof(BinaryOperator), typeof(Number) }, @"\pi \neq 5\wedge 3")]
[InlineData(@"\udots", new[] { typeof(Ordinary) }, @"\udots ")]
// control space
[InlineData(@"x \ y", new[] { typeof(Variable), typeof(Ordinary), typeof(Variable) }, @"x\ y")]
// spacing
Expand Down Expand Up @@ -96,6 +97,22 @@ public void ControlWordDoesNotConsumeFollowingStar() {
Assert.Equal(@"\sin *", LaTeXParser.MathListToLaTeX(list).ToString());
}

[Fact]
public void TestUdotsPreservesOrdinaryNucleusInScriptsAndTables() {
var direct = Assert.IsType<Ordinary>(ParseLaTeX(@"\udots").Atoms[0]);
Assert.Equal("\u22F0", direct.Nucleus);
Assert.Equal(@"\udots ", LaTeXParser.MathListToLaTeX(new MathList(direct)).ToString());

var scripted = Assert.IsType<Ordinary>(ParseLaTeX(@"\udots^a_b").Atoms[0]);
Assert.Equal("\u22F0", scripted.Nucleus);
Assert.NotNull(scripted.Superscript);
Assert.NotNull(scripted.Subscript);

var matrix = Assert.IsType<Table>(ParseLaTeX(@"\begin{matrix}\udots&x\\y&\udots\end{matrix}").Atoms[0]);
Assert.Equal("\u22F0", matrix.Cells[0][0].Atoms.OfType<Ordinary>().Single().Nucleus);
Assert.Equal("\u22F0", matrix.Cells[1][1].Atoms.OfType<Ordinary>().Single().Nucleus);
}

/// new[] { Base list }, new[] { Script of first atom }, new[] { Script of first atom inside script of first atom }
[Theory]
[InlineData("x^2", "x^2", new[] { typeof(Variable) }, new[] { typeof(Number) })]
Expand Down
3 changes: 2 additions & 1 deletion CSharpMath/Atom/LaTeXSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,7 @@ atom is Accent accent
{ @"\dag", new Ordinary("†") },
{ @"\ddag", new Ordinary("‡") },
{ @"\dots", new Ordinary("…") },
{ @"\udots", new Ordinary("⋰") },
{ @"\pounds", new Ordinary("£") },
// \{ is defined in Table 1
// \} is defined in Table 1
Expand Down Expand Up @@ -1189,4 +1190,4 @@ atom is Accent accent
// \varsupsetneqq -> ⫌ + U+FE00 (Variation Selector 1) Not dealing with variation selectors, thank you very much
};
}
}
}
Loading