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
2 changes: 1 addition & 1 deletion src/commands/math/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ const FractionChooseCreateLeftOfMixin = <TBase extends Constructor<MathCommand>>
while (
leftward &&
!(
leftward instanceof BinaryOperator ||
(leftward instanceof BinaryOperator && !(leftward instanceof LatexCmds.factorial)) ||
('text' in LatexCmds && leftward instanceof LatexCmds.text) ||
leftward instanceof UpperLowerLimitCommand ||
leftward.ctrlSeq === '\\ ' ||
Expand Down
13 changes: 13 additions & 0 deletions src/commands/mathElements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -716,11 +716,13 @@ export class Fraction extends MathCommand {
let numBlocks = 0;
let haveDigits = false;
let numPeriods = 0;
let newBlock = false;
this.ends[dir]?.eachChild((child: TNode) => {
if (child instanceof Digit) haveDigits = true;
if (child instanceof VanillaSymbol && child.ctrlSeq === '.') ++numPeriods;

if (
newBlock ||
!(
child instanceof Digit ||
(child instanceof VanillaSymbol && child.ctrlSeq === '.' && numPeriods < 2 && !numBlocks) ||
Expand All @@ -730,6 +732,11 @@ export class Fraction extends MathCommand {
)
++numBlocks;

// These are things that terminate a block. Anything typed after them
// starts a new block and increments the block count above.
newBlock =
('factorial' in LatexCmds && child instanceof LatexCmds.factorial) || child instanceof SupSub;

if (
(haveDigits && numBlocks) ||
numBlocks > 1 ||
Expand Down Expand Up @@ -838,11 +845,13 @@ export const supSubText = (prefix: string, block?: TNode) => {
let numBlocks = 0;
let haveDigits = false;
let numPeriods = 0;
let newBlock = false;
block?.eachChild((child: TNode) => {
if (child instanceof Digit) haveDigits = true;
if (child instanceof VanillaSymbol && child.ctrlSeq === '.') ++numPeriods;

if (
newBlock ||
!(
child instanceof Digit ||
(child instanceof VanillaSymbol && child.ctrlSeq === '.' && numPeriods < 2 && !numBlocks) ||
Expand All @@ -851,6 +860,10 @@ export const supSubText = (prefix: string, block?: TNode) => {
)
++numBlocks;

// These are things that terminate a block. Anything typed after them
// starts a new block and increments the block count above.
newBlock = 'factorial' in LatexCmds && child instanceof LatexCmds.factorial;

if (
(haveDigits && numBlocks) ||
numBlocks > 1 ||
Expand Down