Skip to content

Commit 6223de5

Browse files
committed
fix: resolve parsing issue with adjacent LaTeX \exp() calls to ensure correct multiplication interpretation
1 parent 11f3154 commit 6223de5

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@
9595
and allows proper algebraic manipulation. Use `.N()` to get numeric approximations
9696
when needed.
9797

98+
- **LaTeX `\exp()` Juxtaposition**: Fixed adjacent `\exp()` calls not parsing as
99+
multiplication. Now `\exp(x)\exp(2)` correctly parses as `e^x · e^2` instead of
100+
producing a parse error. The expression then simplifies to `e^{x+2}` as expected.
101+
98102
### Features
99103

100104
- **([#163](https://github.com/cortex-js/compute-engine/issues/163)) Additional

src/compute-engine/latex-syntax/dictionary/definitions-arithmetic.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -699,11 +699,19 @@ export const DEFINITIONS_ARITHMETIC: LatexDictionary = [
699699
{
700700
kind: 'function',
701701
symbolTrigger: 'exp',
702-
parse: 'Exp',
702+
parse: (parser: Parser) => {
703+
const args = parser.parseArguments('implicit');
704+
if (args === null) return 'Exp' as Expression;
705+
return ['Exp', ...args] as Expression;
706+
},
703707
},
704708
{
705709
latexTrigger: '\\exp',
706-
parse: 'Exp',
710+
parse: (parser: Parser) => {
711+
const args = parser.parseArguments('implicit');
712+
if (args === null) return 'Exp' as Expression;
713+
return ['Exp', ...args] as Expression;
714+
},
707715
},
708716
{
709717
name: 'ImaginaryUnit',

0 commit comments

Comments
 (0)