Skip to content

Commit 99bd3aa

Browse files
authored
Merge branch 'develop' into issue3406
2 parents 597dd77 + 27c47f3 commit 99bd3aa

Some content is hidden

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

61 files changed

+3039
-1980
lines changed

components/mjs/input/tex/extension.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ export function fontExtension(id, name, pkg = `@mathjax/${name}`) {
77
const path = name.replace(/-font-extension$/, '-extension');
88
const jax = (MathJax.config?.startup?.output || 'chtml');
99
combineDefaults(MathJax.config.loader, 'paths', {[path]: FONTPATH});
10-
combineDefaults(MathJax.config.loader, 'dependencies', {[`[${path}]/${jax}`]: [`output/${jax}`]});
10+
if (!MathJax._.output?.[jax]) {
11+
combineDefaults(MathJax.config.loader, 'dependencies', {[`[${path}]/${jax}`]: [`output/${jax}`]});
12+
}
1113
MathJax.loader.addPackageData(id, {
1214
extraLoads: [`[${path}]/${jax}`],
1315
rendererExtensions: [path]

components/mjs/output/util.js

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,29 @@ import {combineDefaults, combineWithMathJax} from '#js/components/global.js';
22
import {Package} from '#js/components/package.js';
33
import {hasWindow} from '#js/util/context.js';
44

5-
export const FONTPATH = hasWindow ?
6-
'https://cdn.jsdelivr.net/npm/@mathjax/%%FONT%%-font':
7-
'@mathjax/%%FONT%%-font';
5+
export const FONTPATH = hasWindow
6+
? 'https://cdn.jsdelivr.net/npm/@mathjax/%%FONT%%-font'
7+
: '@mathjax/%%FONT%%-font';
8+
9+
export function configFont(font, jax, config, extension = '') {
10+
const path = (config.fontPath || (FONTPATH + extension));
11+
const name = (font.match(/^[a-z]+:/) ? (font.match(/[^/:\\]*$/) || [jax])[0] : font);
12+
combineDefaults(MathJax.config.loader, 'paths', {
13+
[name+extension]: (name === font ? path.replace(/%%FONT%%/g, font) : font)
14+
});
15+
return `[${name}${extension}]`;
16+
}
17+
18+
export function configExtensions(jax, config) {
19+
const extensions = [];
20+
for (const name of (config.fontExtensions || [])) {
21+
const font = configFont(name, jax, config, '-extension');
22+
const module = `${font}/${jax}`
23+
extensions.push(module);
24+
}
25+
return extensions;
26+
}
27+
828
export const OutputUtil = {
929
config(jax, jaxClass, defaultFont, fontClass) {
1030

@@ -20,15 +40,15 @@ export const OutputUtil = {
2040
}
2141

2242
if (font.charAt(0) !== '[') {
23-
const path = (config.fontPath || FONTPATH);
24-
const name = (font.match(/^[a-z]+:/) ? (font.match(/[^/:\\]*$/) || [jax])[0] : font);
25-
combineDefaults(MathJax.config.loader, 'paths', {
26-
[name]: (name === font ? path.replace(/%%FONT%%/g, font) : font)
27-
});
28-
font = `[${name}]`;
43+
font = configFont(font, jax, config);
2944
}
3045
const name = font.substring(1, font.length - 1);
3146

47+
const extensions = configExtensions(jax, config);
48+
if (extensions.length) {
49+
MathJax.loader.addPackageData(`${font}/${jax}`, {extraLoads: extensions});
50+
}
51+
3252
if (name !== defaultFont || !fontClass) {
3353

3454
MathJax.loader.addPackageData(`output/${jax}`, {extraLoads: [`${font}/${jax}`]});

components/mjs/startup/hasown.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import {MathJax} from '#js/components/global.js';
2+
3+
if (!Object.hasOwn && MathJax.config.startup.polyfillHasOwn) {
4+
Object.hasOwn = function (el, prop) {
5+
if (typeof el === 'undefined' || el === null) {
6+
throw new TypeError('Cannot convert undefined or null to object');
7+
}
8+
return Object.prototype.hasOwnProperty.call(Object(el), prop);
9+
}
10+
}

components/mjs/startup/init.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import './hasown.js'; // Can be removed with ES2024 implementation of Object.hasown
12
import './lib/startup.js';
23

34
import {combineDefaults} from '#js/components/global.js';

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
"cjs:components:compile": "pnpm -s log:single 'Compiling component files'; pnpm tsc --project tsconfig/components.json",
101101
"cjs:components:copy": "pnpm copyfiles -u 2 -e 'components/mjs/**/*.js' 'components/mjs/**/*' components/cjs",
102102
"cjs:components:finalize": "pnpm -s log:comp 'Finalize cjs components'; pnpm -s cjs:components:copy && pnpm -s copy:pkg components/cjs && pnpm -s clean:lib cjs",
103-
"cjs:components:make": "make() { pnpm -s log:single 'Making cjs components'; components/bin/makeAll --cjs --terse --bundle-cjs $1 components/cjs; }; make",
103+
"cjs:components:make": "make() { pnpm -s log:single 'Making cjs components'; node components/bin/makeAll --cjs --terse --bundle-cjs $1 components/cjs; }; make",
104104
"cjs:components:src:build": "pnpm -s log:comp 'Building cjs components sources'; pnpm cjs:components:clean && pnpm cjs:components:compile && pnpm cjs:components:finalize",
105105
"cjs:src:build": "pnpm -s log:comp 'Building cjs sources'; pnpm -s link:src && pnpm clean:dir cjs && pnpm -s cjs:compile && pnpm -s copy:assets cjs && pnpm -s copy:pkg cjs",
106106
"cjs:copy:components": "pnpm -s log:single 'Moving cjs files from components' && pnpm copyfiles -u 2 'components/mjs/**/*.cjs' 'components/mjs/**/*.d.cts' components/cjs",
@@ -110,7 +110,7 @@
110110
"mjs:bundle:finalize": "pnpm -s log:single 'Finalize mjs bundle'; echo '{\n \"type\": \"commonjs\"\n}' > bundle/package.json;",
111111
"mjs:compile": "pnpm -s log:single 'Compiling mjs typescript files'; pnpm tsc --project tsconfig/mjs.json && pnpm tsc --project tsconfig/worker.json",
112112
"mjs:components:build": "pnpm -s log:comp 'Compiling mjs component files'; pnpm clean:lib mjs && pnpm clean:dir bundle && pnpm mjs:components:make && pnpm mjs:bundle:finalize",
113-
"mjs:components:make": "pnpm -s log:single 'Making mjs components'; components/bin/makeAll --mjs --terse components/mjs",
113+
"mjs:components:make": "pnpm -s log:single 'Making mjs components'; node components/bin/makeAll --mjs --terse components/mjs",
114114
"mjs:src:build": "pnpm -s log:comp 'Building mjs sources'; pnpm -s link:src && pnpm -s clean:dir mjs && pnpm -s mjs:compile && pnpm -s copy:assets mjs",
115115
"=============================================================================== mml3": "",
116116
"mml3:make:xslt": "pnpm xslt3 -t -xsl:/tmp/mml3.xsl -export:ts/input/mathml/mml3/mml3.sef.json -nogo",
@@ -132,7 +132,7 @@
132132
"build-mjs": "pnpm -s mjs:build",
133133
"make-cjs-components": "pnpm -s cjs:components:make && pnpm -s cjs:bundle:finalize",
134134
"make-mjs-components": "pnpm -s mjs:components:make",
135-
"make-one": "make() { components/bin/makeAll --no-subdirs $3 $4 --${2:-mjs} components/${2-:mjs}/$1; }; make",
135+
"make-one": "make() { node components/bin/makeAll --no-subdirs $3 $4 --${2:-mjs} components/${2-:mjs}/$1; }; make",
136136
"make-components": "pnpm -s make-mjs-components",
137137
"compile": "pnpm -s compile-mjs",
138138
"build": "pnpm -s build-mjs",

testsuite/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
},
1515
"dependencies": {
1616
"@jest/globals": "^29.7.0",
17-
"@mathjax/mathjax-bbm-font-extension": "0.4.2-beta.8",
17+
"@mathjax/mathjax-bbm-font-extension": "^4.0.0",
1818
"@types/jest": "^29.5.14",
1919
"jest": "^29.7.0",
2020
"ts-jest": "^29.3.4",

testsuite/pnpm-lock.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)