File tree Expand file tree Collapse file tree
testsuite/tests/input/tex Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -552,6 +552,28 @@ describe('Newcommand', () => {
552552
553553 /********************************************************************************/
554554
555+ it ( 'Def Template Brace Removal' , ( ) => {
556+ toXmlMatch (
557+ tex2mml ( '\\def\\test#1\\end{\\text{#1}} \\test{a b}\\end' ) ,
558+ `<math xmlns="http://www.w3.org/1998/Math/MathML" data-latex="\\def\\test#1\\end{\\text{#1}} \\test{a b}\\end" display="block">
559+ <mtext data-latex="\\text{a b}">a b</mtext>
560+ </math>`
561+ ) ;
562+ } ) ;
563+
564+ /********************************************************************************/
565+
566+ it ( 'Def Template Brace Retention' , ( ) => {
567+ toXmlMatch (
568+ tex2mml ( '\\def\\test#1\\end{\\text{#1}} \\test{a}{b}\\end' ) ,
569+ `<math xmlns="http://www.w3.org/1998/Math/MathML" data-latex="\\def\\test#1\\end{\\text{#1}} \\test{a}{b}\\end" display="block">
570+ <mtext data-latex="\\text{{a}{b}}">{a}{b}</mtext>
571+ </math>`
572+ ) ;
573+ } ) ;
574+
575+ /********************************************************************************/
576+
555577 it ( 'Def Hash Replacement' , ( ) => {
556578 toXmlMatch (
557579 tex2mml ( '\\def\\x#1{\\def\\y##1#1{[##1]}\\y} \\x\\X abc \\X' ) ,
Original file line number Diff line number Diff line change @@ -200,16 +200,13 @@ export const NewcommandUtil = {
200200 }
201201 let i = parser . i ;
202202 let j = 0 ;
203- let hasBraces = 0 ;
203+ let hasBraces = false ;
204204 while ( parser . i < parser . string . length ) {
205205 const c = parser . string . charAt ( parser . i ) ;
206206 // @test Def Let, Def Optional Brace, Def Options CS
207207 if ( c === '{' ) {
208208 // @test Def Optional Brace, Def Options CS
209- if ( parser . i === i ) {
210- // @test Def Optional Brace
211- hasBraces = 1 ;
212- }
209+ hasBraces = parser . i === i ;
213210 parser . GetArgument ( name ) ;
214211 j = parser . i - i ;
215212 } else if ( this . MatchParam ( parser , param ) ) {
@@ -224,7 +221,7 @@ export const NewcommandUtil = {
224221 // @test Def Options CS
225222 parser . i ++ ;
226223 j ++ ;
227- hasBraces = 0 ;
224+ hasBraces = false ;
228225 const match = parser . string . substring ( parser . i ) . match ( / [ a - z ] + | ./ i) ;
229226 if ( match ) {
230227 // @test Def Options CS
@@ -235,7 +232,7 @@ export const NewcommandUtil = {
235232 // @test Def Let
236233 parser . i ++ ;
237234 j ++ ;
238- hasBraces = 0 ;
235+ hasBraces = false ;
239236 }
240237 }
241238 // @test Runaway Argument
You can’t perform that action at this time.
0 commit comments