@@ -19,13 +19,15 @@ private Action<TextAtom> CheckAtom<T>
19
19
[ InlineData ( "123.456" ) ]
20
20
[ InlineData ( "abc" ) ]
21
21
[ InlineData ( "abc" , "123" ) ]
22
+ [ InlineData ( "123" , "abc" ) ]
22
23
[ InlineData ( "12" , "a.m." ) ]
23
24
[ InlineData ( "1," , "2," , "3" ) ]
24
25
[ InlineData ( "1,," , "2,," , "3" ) ]
25
26
[ InlineData ( "1,,," ) ]
26
27
[ InlineData ( "1,,," , "2" ) ]
27
28
[ InlineData ( "1()" , "a" ) ]
28
29
[ InlineData ( "a," , "b," , "c" ) ]
30
+ [ InlineData ( "a,." , "b,." , "c" ) ]
29
31
[ InlineData ( "a,," , "b,," , "c" ) ]
30
32
[ InlineData ( "1/" , "2/" , "3" ) ]
31
33
[ InlineData ( "!@*()" ) ]
@@ -57,6 +59,51 @@ public void Command(string input, string output, params string[] text) {
57
59
Assert . Equal ( output , TextLaTeXParser . TextAtomToLaTeX ( atom ) . ToString ( ) ) ;
58
60
}
59
61
[ Theory ]
62
+ [ InlineData ( @"\color{red}␣a" , "a" , null , @"\color{red}{a}" ) ]
63
+ [ InlineData ( @"\color{red}␣{a}" , "a" , null , @"\color{red}{a}" ) ]
64
+ [ InlineData ( @"\color{red}␣😀" , "😀" , null , @"\color{red}{😀}" ) ]
65
+ [ InlineData ( @"\color{red}␣{😀}" , "😀" , null , @"\color{red}{😀}" ) ]
66
+ [ InlineData ( @"\color{red}␣\textbar" , "|" , null , @"\color{red}{\textbar }" ) ]
67
+ [ InlineData ( @"\color{red}␣{\textbar}" , "|" , null , @"\color{red}{\textbar }" ) ]
68
+ [ InlineData ( @"\color{red}␣aa" , "a" , "a" , @"\color{red}{a}a" ) ]
69
+ [ InlineData ( @"\color{red}␣{a}a" , "a" , "a" , @"\color{red}{a}a" ) ]
70
+ [ InlineData ( @"\color{red}␣a😄" , "a" , "😄" , @"\color{red}{a}😄" ) ]
71
+ [ InlineData ( @"\color{red}␣{a}😄" , "a" , "😄" , @"\color{red}{a}😄" ) ]
72
+ [ InlineData ( @"\color{red}␣😀a" , "😀" , "a" , @"\color{red}{😀}a" ) ]
73
+ [ InlineData ( @"\color{red}␣{😀}a" , "😀" , "a" , @"\color{red}{😀}a" ) ]
74
+ [ InlineData ( @"\color{red}␣😀😄" , "😀" , "😄" , @"\color{red}{😀}😄" ) ]
75
+ [ InlineData ( @"\color{red}␣{😀}😄" , "😀" , "😄" , @"\color{red}{😀}😄" ) ]
76
+ [ InlineData ( @"\color{red}␣\textbar a" , "|" , "a" , @"\color{red}{\textbar }a" ) ]
77
+ [ InlineData ( @"\color{red}␣{\textbar}a" , "|" , "a" , @"\color{red}{\textbar }a" ) ]
78
+ [ InlineData ( @"\color{red}␣a\textbar" , "a" , "|" , @"\color{red}{a}\textbar " ) ]
79
+ [ InlineData ( @"\color{red}␣{a}\textbar" , "a" , "|" , @"\color{red}{a}\textbar " ) ]
80
+ [ InlineData ( @"\color{red}␣\textbar\textbar" , "|" , "|" , @"\color{red}{\textbar }\textbar " ) ]
81
+ [ InlineData ( @"\color{red}␣{\textbar}\textbar" , "|" , "|" , @"\color{red}{\textbar }\textbar " ) ]
82
+ [ InlineData ( @"\color{red}␣\textbar😄" , "|" , "😄" , @"\color{red}{\textbar }😄" ) ]
83
+ [ InlineData ( @"\color{red}␣{\textbar}😄" , "|" , "😄" , @"\color{red}{\textbar }😄" ) ]
84
+ [ InlineData ( @"\color{red}␣😀\textbar" , "😀" , "|" , @"\color{red}{😀}\textbar " ) ]
85
+ [ InlineData ( @"\color{red}␣{😀}\textbar" , "😀" , "|" , @"\color{red}{😀}\textbar " ) ]
86
+ public void CommandArguments ( string input , string colored , string ? after , string output ) {
87
+ void Test ( string input ) {
88
+ var atom = Parse ( input ) ;
89
+ var list = new List < TextAtom > {
90
+ new TextAtom . Color ( new TextAtom . Text ( colored ) , Structures . Color . PredefinedColors [ "red" ] )
91
+ } ;
92
+ if ( after != null ) list . Add ( new TextAtom . Text ( after ) ) ;
93
+ Assert . Equal ( list . Count == 1 ? list [ 0 ] : new TextAtom . List ( list ) , atom ) ;
94
+ Assert . Equal ( output , TextLaTeXParser . TextAtomToLaTeX ( atom ) . ToString ( ) ) ;
95
+ }
96
+ Test ( input . Replace ( "␣" , "" ) ) ;
97
+ Test ( input . Replace ( "␣" , " " ) ) ;
98
+ Test ( input . Replace ( "␣" , " " ) ) ;
99
+ Test ( input . Replace ( "␣" , "\r " ) ) ;
100
+ Test ( input . Replace ( "␣" , "\n " ) ) ;
101
+ Test ( input . Replace ( "␣" , "\r \n " ) ) ;
102
+ Test ( input . Replace ( "␣" , " \r " ) ) ;
103
+ Test ( input . Replace ( "␣" , " \n " ) ) ;
104
+ Test ( input . Replace ( "␣" , " \r \n " ) ) ;
105
+ }
106
+ [ Theory ]
60
107
[ InlineData ( @"\textbb" , Atom . FontStyle . Blackboard ) ]
61
108
[ InlineData ( @"\textbf" , Atom . FontStyle . Bold ) ]
62
109
[ InlineData ( @"\textrm" , Atom . FontStyle . Default ) ] // Default is converted to Roman
@@ -234,14 +281,14 @@ public void Accent(string command, string accent) {
234
281
[ InlineData ( @"\$\[\$\]\$" , @"\$" , @"\$" , true , @"\$" , @"\$\[\$ \]\$" ) ]
235
282
236
283
// https://github.com/verybadcat/CSharpMath/issues/113
237
- // [InlineData(@",$,$,", @",", @",,", false, @"" , @",\(,, \)")]
238
- // [InlineData(@",\(,$,", @",", @",,", false, @"" , @",\(,, \)")]
239
- // [InlineData(@",$,\),", @",", @",,", false, @"" , @",\(,, \)")]
240
- // [InlineData(@",\(,\),", @",", @",,", false, @"" , @",\(,, \)")]
241
- // [InlineData(@",$$,$$,", @",", @",, ", true, @"", @",\[,, \] ")]
242
- // [InlineData(@",\[,$$,", @",", @",, ", true, @"", @",\[,, \] ")]
243
- // [InlineData(@",$$,\],", @",", @",, ", true, @"", @",\[,, \] ")]
244
- // [InlineData(@",\[,\],", @",", @",, ", true, @"", @",\[,, \] ")]
284
+ [ InlineData ( @",$,$," , @"," , @",," , false , null , @",\(,,\)" ) ]
285
+ [ InlineData ( @",\(,$," , @"," , @",," , false , null , @",\(,,\)" ) ]
286
+ [ InlineData ( @",$,\)," , @"," , @",," , false , null , @",\(,,\)" ) ]
287
+ [ InlineData ( @",\(,\)," , @"," , @",," , false , null , @",\(,,\)" ) ]
288
+ [ InlineData ( @",$$,$$," , @"," , @"," , true , @", " , @",\[,\], " ) ]
289
+ [ InlineData ( @",\[,$$," , @"," , @"," , true , @", " , @",\[,\], " ) ]
290
+ [ InlineData ( @",$$,\]," , @"," , @"," , true , @", " , @",\[,\], " ) ]
291
+ [ InlineData ( @",\[,\]," , @"," , @"," , true , @", " , @",\[,\], " ) ]
245
292
public void Math ( string input , string ? textBefore , string math , bool display , string ? textAfter , string output ) {
246
293
var atom = Parse ( input ) ;
247
294
var list = new List < TextAtom > ( ) ;
0 commit comments