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 @@ -12191,7 +12191,7 @@ describe('Character Class Changes', () => {
1219112191
1219212192 /********************************************************************************/
1219312193
12194- it ( 'Mathop No Apply' , ( ) => {
12194+ it ( 'Mathop No Apply I ' , ( ) => {
1219512195 toXmlMatch (
1219612196 tex2mml ( '\\mathop{} x' ) ,
1219712197 `<math xmlns="http://www.w3.org/1998/Math/MathML" data-latex="\\mathop{} x" display="block">
@@ -12203,6 +12203,21 @@ describe('Character Class Changes', () => {
1220312203
1220412204 /********************************************************************************/
1220512205
12206+ it ( 'Mathop no Apply II' , ( ) => {
12207+ toXmlMatch (
12208+ tex2mml ( '\\mathop{\\mathrm{}{}} x' ) ,
12209+ `<math xmlns="http://www.w3.org/1998/Math/MathML" data-latex="\\mathop{\\mathrm{}{}} x" display="block">
12210+ <mrow data-mjx-texclass="OP" data-latex="\\mathop{\\mathrm{}{}}">
12211+ <mrow data-mjx-texclass="ORD" data-latex="\\mathrm{}"></mrow>
12212+ <mrow data-mjx-texclass="ORD" data-latex="{}"></mrow>
12213+ </mrow>
12214+ <mi data-latex="x">x</mi>
12215+ </math>`
12216+ ) ;
12217+ } ) ;
12218+
12219+ /********************************************************************************/
12220+
1220612221 it ( 'Mathrel' , ( ) => {
1220712222 toXmlMatch (
1220812223 tex2mml ( '\\mathrel{R}' ) ,
Original file line number Diff line number Diff line change @@ -144,6 +144,7 @@ export interface MmlNode extends Node<MmlNode, MmlNodeClass> {
144144 readonly isSpacelike : boolean ;
145145 readonly linebreakContainer : boolean ;
146146 readonly linebreakAlign : string ;
147+ readonly isEmpty : boolean ;
147148
148149 /**
149150 * The expected number of children (-1 means use inferred mrow)
@@ -540,6 +541,16 @@ export abstract class AbstractMmlNode
540541 return 'data-align' ;
541542 }
542543
544+ /**
545+ * @returns {string } True if all child nodes are empty
546+ */
547+ public get isEmpty ( ) : boolean {
548+ for ( const child of this . childNodes ) {
549+ if ( ! child . isEmpty ) return false ;
550+ }
551+ return true ;
552+ }
553+
543554 /**
544555 * @returns {number } The number of children allowed, or Infinity for any number,
545556 * or -1 for when an inferred row is needed for the children.
@@ -1023,6 +1034,18 @@ export abstract class AbstractMmlTokenNode extends AbstractMmlNode {
10231034 return true ;
10241035 }
10251036
1037+ /**
1038+ * @override
1039+ */
1040+ public get isEmpty ( ) {
1041+ for ( const child of this . childNodes ) {
1042+ if ( ! ( child instanceof TextNode ) || child . getText ( ) . length ) {
1043+ return false ;
1044+ }
1045+ }
1046+ return true ;
1047+ }
1048+
10261049 /**
10271050 * Get the text of the token node (skipping mglyphs, and combining
10281051 * multiple text nodes)
Original file line number Diff line number Diff line change @@ -788,7 +788,7 @@ export class FnItem extends BaseItem {
788788 }
789789 }
790790 // @test Mathop Apply, Mathop No Apply
791- if ( top . isKind ( 'TeXAtom' ) && top . childNodes [ 0 ] . childNodes . length === 0 ) {
791+ if ( top . isKind ( 'TeXAtom' ) && top . isEmpty ) {
792792 return [ [ top , item ] , true ] ;
793793 }
794794 // @test Named Function, Named Function Arg
You can’t perform that action at this time.
0 commit comments