Skip to content

Commit a7b3be6

Browse files
authored
Merge pull request #1437 from mathjax/develop
Merge v4.1.1 into master branch
2 parents 60ed165 + 88c74d0 commit a7b3be6

File tree

48 files changed

+1318
-717
lines changed

Some content is hidden

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

48 files changed

+1318
-717
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ await MathJax.init({
9999
loader: {load: ['input/tex', 'output/svg']}
100100
});
101101
const svg = await MathJax.tex2svgPromise('\\frac{1}{x^2-1}', {display: true});
102-
console.log(MathJax.startup.adaptor.outerHTML(svg));
102+
console.log(MathJax.startup.adaptor.serializeXML(svg));
103103
```
104104

105105

@@ -119,7 +119,7 @@ MathJax.init({
119119
loader: {load: ['input/tex', 'output/svg']}
120120
}).then(() => {
121121
const svg = MathJax.tex2svg('\\frac{1}{x^2-1}', {display: true});
122-
console.log(MathJax.startup.adaptor.outerHTML(svg));
122+
console.log(MathJax.startup.adaptor.serializeXML(svg));
123123
}).catch((err) => console.log(err.message));
124124
```
125125

components/bin/copy

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,10 @@ const bundle = (process.argv[3] || 'bundle');
4848
const json = path.resolve(process.argv[4] || '.', 'config.json');
4949
let configs = require(json).copy;
5050
if (!configs) process.exit();
51-
const wd = path.dirname(json);
52-
process.chdir(wd);
5351
if (!Array.isArray(configs)) {
5452
configs = [configs];
5553
}
54+
process.chdir(path.dirname(json));
5655

5756
/**
5857
* Get the directory for node modules (either the parent of the MathJax directory,
@@ -61,6 +60,13 @@ if (!Array.isArray(configs)) {
6160
const parent = path.resolve(__dirname, '..', '..');
6261
const nodeDir = (dir => (fs.existsSync(dir) ? dir : path.resolve(parent, '..')))(path.join(parent, 'node_modules'));
6362

63+
/**
64+
* Other top-level directories
65+
*/
66+
const tsDir = path.resolve(parent, 'ts');
67+
const jsDir = path.resolve(parent, target);
68+
const bundleDir = path.resolve(parent, bundle);
69+
6470
/**
6571
* Copy a file or directory tree
6672
*
@@ -84,14 +90,28 @@ function copyFile(from, to, name, space) {
8490
}
8591
}
8692

93+
/**
94+
* @param {string} name The file name to process
95+
* @returns {string} The name with paths replaced by full directories
96+
*/
97+
function resolvePaths(name) {
98+
return path.resolve(
99+
process.cwd(),
100+
name.replace(/^\[node\]/, nodeDir)
101+
.replace(/^\[ts\]/, tsDir)
102+
.replace(/^\[js\]/, jsDir)
103+
.replace(/^\[bundle\]/, bundleDir)
104+
);
105+
}
106+
87107
/**
88108
* Handle the copying for a given configuration
89109
*
90110
* @param {{from: string, to: string, copy: string[]}} config The configuration for the copy operation
91111
*/
92112
function processConfig(config) {
93-
const to = path.resolve(wd, config.to.replace(/\/bundle(\/|$)/, '/' + bundle + '$1'));
94-
const from = path.resolve(wd, config.from.replace(/\[node\]/, nodeDir));
113+
const to = resolvePaths(config.to);
114+
const from = resolvePaths(config.from);
95115
for (const name of config.copy) {
96116
copyFile(from, to, name, '');
97117
}

components/bin/pack

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,17 @@ async function readJSON(dir) {
7474
return new Promise((ok, fail) => {
7575
const buffer = [];
7676
const child = spawn(
77-
'npx',
77+
'node',
7878
[
79-
'webpack',
79+
require.resolve(path.join('webpack', 'bin', 'webpack.js')),
8080
'--env', `dir=${path.relative(packDir, path.resolve(dir))}`,
8181
'--env', `bundle=${bundle}`,
8282
'--json',
8383
'-c', path.relative(packDir, path.join(compPath, 'webpack.config.' + target))
8484
],
8585
{
8686
cwd: packDir,
87-
shell: true,
87+
shell: process.platform === 'Win32',
8888
}
8989
);
9090
child.stdout.on('data', (data) => buffer.push(String(data)));

components/mjs/a11y/sre/worker/config.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"name": "sre/speech-worker"
44
},
55
"copy": {
6-
"to": "../../../../../bundle/sre",
7-
"from": "../../../../../ts/a11y/sre",
6+
"to": "[bundle]/sre",
7+
"from": "[ts]/a11y/sre",
88
"copy": [
99
"require.mjs",
1010
"require.d.mts"

components/mjs/input/mml/extensions/mml3/config.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"excludeSubdirs": true
77
},
88
"copy": {
9-
"to": "../../../../../../bundle/input/mml/extensions",
10-
"from": "../../../../../../ts/input/mathml/mml3",
9+
"to": "[bundle]/input/mml/extensions",
10+
"from": "[ts]/input/mathml/mml3",
1111
"copy": [
1212
"mml3.sef.json"
1313
]

components/mjs/node-main/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"copy": {
3-
"to": "../../../bundle",
3+
"to": "[bundle]",
44
"from": ".",
55
"copy": [
66
"node-main.mjs",

components/mjs/output/util.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
import {combineDefaults, combineWithMathJax} from '#js/components/global.js';
22
import {Package} from '#js/components/package.js';
33
import {hasWindow} from '#js/util/context.js';
4+
import {mathjax} from '#js/mathjax.js'
45

56
export function configFont(font, jax, config, extension = '') {
6-
const path = (config.fontPath || `[fonts]/%%FONT%%-font${extension}`);
7+
const version =
8+
(MathJax.config.loader?.paths?.fonts || '').substring(0, 24) === 'https://cdn.jsdelivr.net'
9+
? `@%%VERSION%%` : '';
10+
const path = (config.fontPath || `[fonts]/%%FONT%%-font${extension}${version}`);
711
const name = (font.match(/^[a-z]+:/) ? (font.match(/[^/:\\]*$/) || [jax])[0] : font);
812
combineDefaults(MathJax.config.loader, 'paths', {
9-
[name+extension]: (name === font ? path.replace(/%%FONT%%/g, font) : font)
13+
[name+extension]: (
14+
name === font
15+
? path.replace(/%%FONT%%/g, font).replace(/%%VERSION%%/g, mathjax.version)
16+
: font
17+
)
1018
});
1119
return `[${name}${extension}]`;
1220
}

components/mjs/require/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"copy": {
3-
"to": "../../../bundle",
3+
"to": "[bundle]",
44
"from": "../..",
55
"copy": [
66
"require.mjs"

components/mjs/source.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ export const source = {
8282
'[mathmaps]': `${src}/../../bundle/sre/mathmaps`,
8383
'ui/lazy': `${src}/ui/lazy/lazy.js`,
8484
'ui/menu': `${src}/ui/menu/menu.js`,
85+
'ui/no-dark-mode': `${src}/ui/nodarkmode/nodarkmode.js`,
8586
'ui/safe': `${src}/ui/safe/safe.js`,
8687
'mml-chtml': `${src}/mml-chtml/mml-chtml.js`,
8788
'mml-chtml-nofont': `${src}/mml-chtml-nofont/mml-chtml-nofont.js`,

components/mjs/sre/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"copy": {
3-
"to": "../../../bundle/sre",
3+
"to": "[bundle]/sre",
44
"from": "[node]/speech-rule-engine/lib",
55
"copy": [
66
"mathmaps"

0 commit comments

Comments
 (0)