@@ -716,11 +716,13 @@ export class Fraction extends MathCommand {
716716 let numBlocks = 0 ;
717717 let haveDigits = false ;
718718 let numPeriods = 0 ;
719+ let newBlock = false ;
719720 this . ends [ dir ] ?. eachChild ( ( child : TNode ) => {
720721 if ( child instanceof Digit ) haveDigits = true ;
721722 if ( child instanceof VanillaSymbol && child . ctrlSeq === '.' ) ++ numPeriods ;
722723
723724 if (
725+ newBlock ||
724726 ! (
725727 child instanceof Digit ||
726728 ( child instanceof VanillaSymbol && child . ctrlSeq === '.' && numPeriods < 2 && ! numBlocks ) ||
@@ -730,6 +732,11 @@ export class Fraction extends MathCommand {
730732 )
731733 ++ numBlocks ;
732734
735+ // These are things that terminate a block. Anything typed after them
736+ // starts a new block and increments the block count above.
737+ newBlock =
738+ ( 'factorial' in LatexCmds && child instanceof LatexCmds . factorial ) || child instanceof SupSub ;
739+
733740 if (
734741 ( haveDigits && numBlocks ) ||
735742 numBlocks > 1 ||
@@ -838,11 +845,13 @@ export const supSubText = (prefix: string, block?: TNode) => {
838845 let numBlocks = 0 ;
839846 let haveDigits = false ;
840847 let numPeriods = 0 ;
848+ let newBlock = false ;
841849 block ?. eachChild ( ( child : TNode ) => {
842850 if ( child instanceof Digit ) haveDigits = true ;
843851 if ( child instanceof VanillaSymbol && child . ctrlSeq === '.' ) ++ numPeriods ;
844852
845853 if (
854+ newBlock ||
846855 ! (
847856 child instanceof Digit ||
848857 ( child instanceof VanillaSymbol && child . ctrlSeq === '.' && numPeriods < 2 && ! numBlocks ) ||
@@ -851,6 +860,10 @@ export const supSubText = (prefix: string, block?: TNode) => {
851860 )
852861 ++ numBlocks ;
853862
863+ // These are things that terminate a block. Anything typed after them
864+ // starts a new block and increments the block count above.
865+ newBlock = 'factorial' in LatexCmds && child instanceof LatexCmds . factorial ;
866+
854867 if (
855868 ( haveDigits && numBlocks ) ||
856869 numBlocks > 1 ||
0 commit comments