Skip to content

Commit 86f6d63

Browse files
committed
Merge branch 'develop' into textcomp_package
2 parents c2b91fb + 53b13c0 commit 86f6d63

41 files changed

Lines changed: 2210 additions & 308 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

components/src/dependencies.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export const dependencies = {
2121
'[tex]/enclose': ['input/tex-base'],
2222
'[tex]/extpfeil': ['input/tex-base', '[tex]/newcommand', '[tex]/ams'],
2323
'[tex]/html': ['input/tex-base'],
24+
'[tex]/mathtools': ['input/tex-base', '[tex]/newcommand', '[tex]/ams'],
2425
'[tex]/mhchem': ['input/tex-base', '[tex]/ams'],
2526
'[tex]/newcommand': ['input/tex-base'],
2627
'[tex]/noerrors': ['input/tex-base'],
@@ -57,6 +58,7 @@ const allPackages = [
5758
'[tex]/enclose',
5859
'[tex]/extpfeil',
5960
'[tex]/html',
61+
'[tex]/mathtools',
6062
'[tex]/mhchem',
6163
'[tex]/newcommand',
6264
'[tex]/noerrors',
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"component": "input/tex/extensions/mathtools",
3+
"targets": ["input/tex/mathtools"]
4+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import './lib/mathtools.js';
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const PACKAGE = require('../../../../../webpack.common.js');
2+
3+
module.exports = PACKAGE(
4+
'input/tex/extensions/mathtools', // the package to build
5+
'../../../../../../js', // location of the MathJax js library
6+
[ // packages to link to
7+
'components/src/input/tex/extensions/ams/lib',
8+
'components/src/input/tex/extensions/newcommand/lib',
9+
'components/src/input/tex-base/lib',
10+
'components/src/core/lib'
11+
],
12+
__dirname // our directory
13+
);

components/src/source.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export const source = {
2323
'[tex]/enclose': `${src}/input/tex/extensions/enclose/enclose.js`,
2424
'[tex]/extpfeil': `${src}/input/tex/extensions/extpfeil/extpfeil.js`,
2525
'[tex]/html': `${src}/input/tex/extensions/html/html.js`,
26+
'[tex]/mathtools': `${src}/input/tex/extensions/mathtools/mathtools.js`,
2627
'[tex]/mhchem': `${src}/input/tex/extensions/mhchem/mhchem.js`,
2728
'[tex]/newcommand': `${src}/input/tex/extensions/newcommand/newcommand.js`,
2829
'[tex]/noerrors': `${src}/input/tex/extensions/noerrors/noerrors.js`,

ts/components/loader.ts

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ declare var document: Document;
4242
* Function used to determine path to a given package.
4343
*/
4444
export type PathFilterFunction = (data: {name: string, original: string, addExtension: boolean}) => boolean;
45-
export type PathFilterList = {[name: string]: PathFilterFunction};
45+
export type PathFilterList = (PathFilterFunction | [PathFilterFunction, number])[];
4646

4747
/**
4848
* Update the configuration structure to include the loader configuration
@@ -57,6 +57,7 @@ export interface MathJaxConfig extends MJConfig {
5757
ready?: PackageReady; // A function to call when MathJax is ready
5858
failed?: PackageFailed; // A function to call when MathJax fails to load
5959
require?: (url: string) => any; // A function for loading URLs
60+
pathFilters?: PathFilterList; // List of path filters (and optional priorities) to add
6061
[name: string]: any; // Other configuration blocks
6162
};
6263
}
@@ -73,7 +74,7 @@ export interface MathJaxObject extends MJObject {
7374
preLoad: (...names: string[]) => void; // Indicate that packages are already loaded by hand
7475
defaultReady: () => void; // The function performed when all packages are loaded
7576
getRoot: () => string; // Find the root URL for the MathJax files
76-
pathFilters: PathFilterList; // the filters to use for looking for package paths
77+
pathFilters: FunctionList; // the filters to use for looking for package paths
7778
};
7879
startup?: any;
7980
}
@@ -117,6 +118,7 @@ export const PathFilters: {[name: string]: PathFilterFunction} = {
117118
}
118119
return true;
119120
}
121+
120122
};
121123

122124

@@ -216,9 +218,9 @@ export namespace Loader {
216218
/**
217219
* The default filters to use.
218220
*/
219-
pathFilters.add(PathFilters.source, 1);
220-
pathFilters.add(PathFilters.normalize, 2);
221-
pathFilters.add(PathFilters.prefix, 5);
221+
pathFilters.add(PathFilters.source, 0);
222+
pathFilters.add(PathFilters.normalize, 10);
223+
pathFilters.add(PathFilters.prefix, 20);
222224
}
223225

224226
/**
@@ -229,6 +231,7 @@ export const MathJax = MJGlobal as MathJaxObject;
229231
/*
230232
* If the loader hasn't been added to the MathJax variable,
231233
* Add the loader configuration, library, and data objects.
234+
* Add any path filters from the configuration.
232235
*/
233236
if (typeof MathJax.loader === 'undefined') {
234237

@@ -242,12 +245,23 @@ if (typeof MathJax.loader === 'undefined') {
242245
load: [],
243246
ready: Loader.defaultReady.bind(Loader),
244247
failed: (error: PackageError) => console.log(`MathJax(${error.package || '?'}): ${error.message}`),
245-
require: null
248+
require: null,
249+
pathFilters: [],
246250
});
247251
combineWithMathJax({
248252
loader: Loader
249253
});
250254

255+
//
256+
// Add any path filters from the configuration
257+
//
258+
for (const filter of MathJax.config.loader.pathFilters) {
259+
if (Array.isArray(filter)) {
260+
Loader.pathFilters.add(filter[0], filter[1]);
261+
} else {
262+
Loader.pathFilters.add(filter);
263+
}
264+
}
251265
}
252266

253267
/**

ts/components/startup.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import {OutputJax} from '../core/OutputJax.js';
3535
import {CommonOutputJax} from '../output/common/OutputJax.js';
3636
import {DOMAdaptor} from '../core/DOMAdaptor.js';
3737
import {PrioritizedList} from '../util/PrioritizedList.js';
38-
import {OptionList} from '../util/Options.js';
38+
import {OptionList, OPTIONS} from '../util/Options.js';
3939

4040
import {TeX} from '../input/tex.js';
4141

@@ -54,6 +54,8 @@ export interface MathJaxConfig extends MJConfig {
5454
typeset?: boolean; // Perform initial typeset?
5555
ready?: () => void; // Function to perform when components are ready
5656
pageReady?: () => void; // Function to perform when page is ready
57+
invalidOption?: 'fatal' | 'warn'; // Do invalid options produce a warning, or throw an error?
58+
optionError?: (message: string, key: string) => void, // Function to report invalid options
5759
[name: string]: any; // Other configuration blocks
5860
};
5961
}
@@ -534,8 +536,8 @@ export const MathJax = MJGlobal as MathJaxObject;
534536

535537
/*
536538
* If the startup module hasn't been added to the MathJax variable,
537-
* Add the startup configuration and data objects, and create
538-
* the initial typeset and conversion calls.
539+
* Add the startup configuration and data objects, and
540+
* set the method for handling invalid options, if provided.
539541
*/
540542
if (typeof MathJax._.startup === 'undefined') {
541543

@@ -555,6 +557,13 @@ if (typeof MathJax._.startup === 'undefined') {
555557
options: {}
556558
});
557559

560+
if (MathJax.config.startup.invalidOption) {
561+
OPTIONS.invalidOption = MathJax.config.startup.invalidOption;
562+
}
563+
if (MathJax.config.startup.optionError) {
564+
OPTIONS.optionError = MathJax.config.startup.optionError;
565+
}
566+
558567
}
559568

560569
/**

ts/core/MmlTree/MmlNodes/mo.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -289,18 +289,6 @@ export class MmlMo extends AbstractMmlTokenNode {
289289
this.texClass = TEXCLASS.CLOSE;
290290
}
291291
}
292-
if (this.getText() === '\u2061') {
293-
//
294-
// Force previous node to be TEXCLASS.OP and skip this node
295-
//
296-
if (prev && prev.getProperty('texClass') === undefined &&
297-
prev.attributes.get('mathvariant') !== 'italic') {
298-
prev.texClass = TEXCLASS.OP;
299-
prev.setProperty('fnOP', true);
300-
}
301-
this.texClass = this.prevClass = TEXCLASS.NONE;
302-
return prev;
303-
}
304292
return this.adjustTeXclass(prev);
305293
}
306294
/**

ts/core/MmlTree/MmlNodes/mstyle.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,16 @@ export class MmlMstyle extends AbstractMmlLayoutNode {
7575
} else {
7676
level = parseInt(scriptlevel);
7777
}
78+
prime = false; // style change resets tex prime style
7879
}
7980
let displaystyle = this.attributes.getExplicit('displaystyle') as boolean;
8081
if (displaystyle != null) {
8182
display = (displaystyle === true);
83+
prime = false; // style change resets tex prime style
84+
}
85+
const cramped = this.attributes.getExplicit('data-cramped') as boolean; // manual control of tex prime style
86+
if (cramped != null) {
87+
prime = cramped;
8288
}
8389
attributes = this.addInheritedAttributes(attributes, this.attributes.getAllAttributes());
8490
this.childNodes[0].setInheritedAttributes(attributes, display, level, prime);

ts/core/MmlTree/MmlNodes/mtable.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,11 @@ export class MmlMtable extends AbstractMmlNode {
106106
/**
107107
* Make sure all children are mtr or mlabeledtr nodes
108108
* Inherit the table attributes, and set the display attribute based on the table's displaystyle attribute
109+
* Reset the prime value to false
109110
*
110111
* @override
111112
*/
112-
protected setChildInheritedAttributes(attributes: AttributeList, display: boolean, level: number, prime: boolean) {
113+
protected setChildInheritedAttributes(attributes: AttributeList, display: boolean, level: number, _prime: boolean) {
113114
for (const child of this.childNodes) {
114115
if (!child.isKind('mtr')) {
115116
this.replaceChild(this.factory.create('mtr'), child)
@@ -122,10 +123,11 @@ export class MmlMtable extends AbstractMmlNode {
122123
columnalign: this.attributes.get('columnalign'),
123124
rowalign: 'center'
124125
});
126+
const cramped = this.attributes.getExplicit('data-cramped') as boolean;
125127
const ralign = split(this.attributes.get('rowalign') as string);
126128
for (const child of this.childNodes) {
127129
attributes.rowalign[1] = ralign.shift() || attributes.rowalign[1];
128-
child.setInheritedAttributes(attributes, display, level, prime);
130+
child.setInheritedAttributes(attributes, display, level, !!cramped);
129131
}
130132
}
131133

0 commit comments

Comments
 (0)