Skip to content

Commit 394fc68

Browse files
committed
Merge branch 'tex_input_typescript' into alpha
2 parents b9f046c + e2a920f commit 394fc68

File tree

5 files changed

+9
-7
lines changed

5 files changed

+9
-7
lines changed

mathjax3-ts/input/tex/OldParser.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ export class OldParser {
6666
}
6767
}
6868
this.stack = new Stack(ENV, !!env);
69-
this.NewParser.setup(this.ParseMethods);
7069
// configurations.forEach(this.NewParser.append.bind(this.NewParser));
7170
this.Parse();
7271
this.Push(new StopItem());

mathjax3-ts/input/tex/ParseMethods.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
// import * as sitem from './StackItem.js';
2626
import * as sitem from './StackItem.js';
27+
import {NewTex} from './Translate.js';
2728
import {Symbol} from './Symbol.js';
2829
import {CharacterMap} from './SymbolMap.js';
2930
import {TreeHelper} from './TreeHelper.js';
@@ -1511,7 +1512,7 @@ export namespace ParseMethods {
15111512
let T = parser.ParseArg(name);
15121513
let S = parser.ParseArg(name);
15131514
let SS = parser.ParseArg(name);
1514-
parser.Push(D);
1515+
parser.Push(NewTex.display ? D : T);
15151516
// parser.Push(MML.TeXmathchoice(D,T,S,SS));
15161517
}
15171518

mathjax3-ts/input/tex/ParserUtil.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,14 @@
2626

2727
import {TEXCLASS, MmlNode} from '../../core/MmlTree/MmlNode.js';
2828
import {TreeHelper} from './TreeHelper.js';
29-
import TexParser from './TexParser.js';
29+
import {OldParser} from './OldParser.js';
3030

3131
// A namespace for utility functions for the TeX Parser.
3232
//
3333
// Will become a Typescript namespace.
3434

3535
export namespace ParserUtil {
3636

37-
export let OldParser = (x:any, {}) => x;
38-
3937
const emPerInch = 7.2;
4038
const pxPerInch = 72;
4139
const UNIT_CASES: {[key: string]: ((m: number) => number)} = {
@@ -148,7 +146,7 @@ export namespace ParserUtil {
148146
}
149147
let D = '{\\bigg' + side + ' ' + fence + '}';
150148
let T = '{\\big' + side + ' ' + fence + '}';
151-
return ParserUtil.OldParser('\\mathchoice' + D + T + T + T, {});
149+
return new OldParser('\\mathchoice' + D + T + T + T, {}, {}).mml();
152150
// let parser = new TexParser();
153151
// return parser.parse('\\mathchoice' + D + T + T + T, {}).mml();
154152
};

mathjax3-ts/input/tex/TexParser.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import {HandlerType, Configuration, ParseInput, ParseResult, ParseMethod} from '
2929
import {BaseMappings} from './BaseMappings.js';
3030
import {AmsMappings} from './AmsMappings.js';
3131
import {AmsSymbols} from './AmsSymbols.js';
32+
import {ParseMethods} from './ParseMethods.js';
3233

3334

3435
/**
@@ -50,6 +51,7 @@ export default class TexParser {
5051
this.configure(BaseMappings.CONFIGURATION);
5152
this.append(AmsMappings.CONFIGURATION);
5253
this.append(AmsSymbols.CONFIGURATION);
54+
this.setup(ParseMethods as any);
5355
}
5456

5557

mathjax3-ts/input/tex/Translate.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ export namespace NewTex {
3737

3838
export type Script = {type: string, innerText: string, MathJax: any};
3939

40+
export let display: boolean = false;
41+
4042
export function Compile(tex: string, display: boolean): MmlNode {
4143
let script = {
4244
type:"math/tex"+(display?"; mode=display":""),
@@ -60,7 +62,7 @@ export namespace NewTex {
6062
let mml: MmlNode;
6163
let isError = false;
6264
let math = script.innerText;
63-
let display = (script.type.replace(/\n/g," ").match(/(;|\s|\n)mode\s*=\s*display(;|\s|\n|$)/) != null);
65+
display = (script.type.replace(/\n/g," ").match(/(;|\s|\n)mode\s*=\s*display(;|\s|\n|$)/) != null);
6466
try {
6567
mml = new OldParser(math, null, ParseMethods as any).mml();
6668
TreeHelper.printSimple(mml.toString());

0 commit comments

Comments
 (0)