Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
206 commits
Select commit Hold shift + click to select a range
ac3ff0e
update diff tool
zorkow Feb 26, 2025
efcdd46
Merge pull request #1333 from mathjax/update/readme
dpvc Aug 4, 2025
20a3d2f
Support tabbing to links internal to an expression. (mathjax/MathJax#…
dpvc Aug 10, 2025
74538f8
Add better shift-tab handling
dpvc Aug 10, 2025
6c6902f
Add missing 'help' menu option
dpvc Aug 16, 2025
e32db09
Add configuration option
dpvc Aug 16, 2025
7772f04
Fix a number of line-breaking problems in tables and elsewhere. (mat…
dpvc Aug 18, 2025
8597321
Fix issue with super in CJS version
dpvc Aug 18, 2025
6176066
Remove uneeded change in common wrapper
dpvc Aug 18, 2025
e504edc
Add support for generic font extensions
dpvc Aug 21, 2025
cf6e63e
Make tags produce separate mtext nodes for the delimiters around the tag
dpvc Aug 28, 2025
7545ae7
Update tags in ams and mathtools packages
dpvc Aug 28, 2025
afaf1ea
Merge pull request #1336 from mathjax/fix/help-option
dpvc Aug 28, 2025
2f26005
Update tests for change in tag output
dpvc Aug 29, 2025
91b530b
Take retry errors into account when resetting generic font
dpvc Aug 29, 2025
2a0414e
remove debugging output
dpvc Aug 29, 2025
8f74777
Use node to call makeAll rather than assuming hash-bang works
dpvc Aug 29, 2025
a1447d2
Don't add invisible funciton apply after an empty mathop
dpvc Sep 1, 2025
90d4aff
Allow spaces after `@` in CD environment, as in real LaTeX. (mathjax…
dpvc Sep 3, 2025
4b8c0cb
Remove use of aria-level
dpvc Sep 3, 2025
8843f12
Updat formatting for prettier
dpvc Sep 3, 2025
5fd2ce4
Update formatting for prettier
dpvc Sep 3, 2025
9882a85
Update formatting for prettier
dpvc Sep 3, 2025
0740675
Update mathtools tag example
dpvc Sep 4, 2025
c97db48
Update lock file
dpvc Sep 4, 2025
5562037
Prevent unwanted forced inline breaks in SVG semantics elements. (ma…
dpvc Sep 6, 2025
20a5452
Fix formatting for prettier
dpvc Sep 6, 2025
9c71731
Don't use padding for horizontal stretchy extenders. (mathjax/MathJa…
dpvc Sep 6, 2025
a226f4b
Better sanitization of styles.
dpvc Sep 7, 2025
a57ed8b
Update operator dictionary to MathML4 version. (mathjax/MathJax#3421)
dpvc Sep 7, 2025
e9d899a
Update tests
dpvc Sep 7, 2025
c417c49
ensures highlighting of all nodes that are spoken
zorkow Sep 9, 2025
1c2bbef
Add comments
zorkow Sep 10, 2025
b919bb0
Provide hasOwn polyfill configuration option.
dpvc Sep 10, 2025
36f1ca5
Change CSS for help icon so that when scroll or truncate is used, it …
dpvc Sep 10, 2025
aa73c47
Fix spelling error and adjust scaling to accommodate new padding need…
dpvc Sep 10, 2025
63fcc30
Remove unneeded quotation escapes
dpvc Sep 11, 2025
dea8100
Update tests to reflect changes to operator dictionary
dpvc Sep 11, 2025
654924f
Fix formatting for prettier
dpvc Sep 11, 2025
23b4433
Use the correct MathML spacing from the operator dictionary
dpvc Sep 11, 2025
20db7c7
rewrite to lazy init and parsing
zorkow Sep 12, 2025
91b1c2d
Only remove left and right padding, so if a stretchy is just extender…
dpvc Sep 15, 2025
2bde9c8
Allow stretched character to increase column size (e.g., if it has mi…
dpvc Sep 15, 2025
5651923
Make the polyfill opt-out rather than opt-in
dpvc Sep 15, 2025
729afb9
Implement a method of enclosing multiple elements when there are extr…
dpvc Sep 16, 2025
d653254
Avoid semantic IDs that are not in the tree
dpvc Sep 16, 2025
3370290
Return after removing the node, as there is no need to go futher in t…
dpvc Sep 16, 2025
5d44b01
Update the position of labels on vertical arrows to better match actu…
dpvc Sep 16, 2025
6ce7bef
Update CD tests for new output
dpvc Sep 16, 2025
ea468ec
Update clip-path CSS to handler older browsers
dpvc Sep 17, 2025
93aef48
introduce subtree caching
zorkow Sep 18, 2025
dcc8bd4
Make dialogs movable and sizable.
dpvc Sep 25, 2025
a88d249
Fix issue with tests
dpvc Sep 25, 2025
da2b264
Fix the MathML spacing for some negated RELs, and correct class of pe…
dpvc Sep 25, 2025
b2c58c0
Remove unneeded TeXAtom nodes in fixStretchy, and update tests
dpvc Sep 25, 2025
6bd36b0
Fix left and right arrows in mhchem
dpvc Sep 25, 2025
e879a48
Update mhchem tests
dpvc Sep 25, 2025
9ea3607
Add keyboard control for sizing and moving, and a help button to expl…
dpvc Sep 25, 2025
d3ef2f0
Updates for prettier
dpvc Sep 25, 2025
9865f06
Fix the tex class for \therefore and \because
dpvc Sep 27, 2025
73e68e3
Update test for therefore and because
dpvc Sep 27, 2025
3093f9f
Allow digits in \operatorname (mathjax/MathJax#2991)
GWDx Sep 27, 2025
f98da55
Fix path handling to work with Windows and add tests for it
dpvc Oct 1, 2025
1af7208
Fix problem with Styles handling of margin. (mathjax/MathJax#3443)
dpvc Oct 2, 2025
d73a2a1
Update build tools to work in Windows
dpvc Oct 3, 2025
0ab25f7
finished review comments
zorkow Oct 5, 2025
ef9b624
Merge pull request #1337 from mathjax/feature/font-extension-config
dpvc Oct 6, 2025
e3a3acc
Merge pull request #1338 from mathjax/issue3415
dpvc Oct 9, 2025
9f7500e
fix typo
zorkow Oct 10, 2025
5d363f4
Merge pull request #1349 from mathjax/fix/split_highlighting
zorkow Oct 10, 2025
2a531d2
Merge pull request #1339 from mathjax/fix/makeAll
dpvc Oct 10, 2025
4318ee0
Merge pull request #1341 from mathjax/fix/function-apply
dpvc Oct 10, 2025
451bd4e
Merge pull request #1343 from mathjax/issue3425
dpvc Oct 10, 2025
64a7fd6
Merge pull request #1344 from mathjax/fix/aria-level
dpvc Oct 10, 2025
c12a9d4
Merge pull request #1346 from mathjax/issue3428
dpvc Oct 10, 2025
98a31f5
Merge pull request #1347 from mathjax/issue3429
dpvc Oct 10, 2025
61c9f29
Merge pull request #1348 from mathjax/fix/style-sanitize
dpvc Oct 10, 2025
560faa4
Merge pull request #1355 from mathjax/update/amscd-labels
dpvc Oct 10, 2025
4d70d40
Merge pull request #1356 from mathjax/update/clip-path
dpvc Oct 10, 2025
6f058dc
Merge pull request #1358 from mathjax/fix/mhchem-arrows
dpvc Oct 10, 2025
495b97b
Add comments requested by review
dpvc Oct 10, 2025
59a9b65
Merge pull request #1351 from mathjax/feature/hasown-polyfill
dpvc Oct 10, 2025
2624516
Make changes suggested in review
dpvc Oct 10, 2025
abf2652
Fix handling of argument to \set and others. (mathjax/MathJax#3447)
dpvc Oct 13, 2025
0c970bb
Prevent circular dependency for tex extensions that load font extensi…
dpvc Oct 13, 2025
c98ed35
Add tests for brace mismatches
dpvc Oct 13, 2025
2613461
Merge pull request #1353 from mathjax/issue3423
dpvc Oct 14, 2025
e9765e6
Merge pull request #1366 from mathjax/fix/font-extension
dpvc Oct 14, 2025
c143fa6
Merge pull request #1365 from mathjax/issue3447
dpvc Oct 14, 2025
85abf0b
Make changes from PR review
dpvc Oct 14, 2025
037f876
Merge pull request #1345 from mathjax/feature/tag-texts
dpvc Oct 14, 2025
fe4921f
Fix for prettier
dpvc Oct 14, 2025
ce9b798
Fix spacing issues with \operatorname. (mathjax/MathJax#3448)
dpvc Oct 15, 2025
8505432
Allow cleanAttributes to work on nodes with no attributes (e.g., XML …
dpvc Oct 16, 2025
01b8b8e
Merge pull request #1350 from mathjax/issue3432
dpvc Oct 17, 2025
49d2acf
Merge pull request #1352 from mathjax/issue3421
dpvc Oct 17, 2025
712294c
Merge pull request #1362 from mathjax/issue3443
dpvc Oct 17, 2025
73aa977
Remove link count in favor of SRE adding it
dpvc Oct 17, 2025
bc11aba
Add option to disable explorer help
dpvc Aug 29, 2025
18c9ec4
Uppdate for prettier
dpvc Oct 17, 2025
0cea67e
Fix unhighlighting foreground colors in SVG, and copy the parts array…
dpvc Oct 17, 2025
0d3cbfd
Merge pull request #1367 from mathjax/issue3448
dpvc Oct 17, 2025
791e311
Merge pull request #1368 from mathjax/fix/cleanAttributes
dpvc Oct 17, 2025
859405e
Merge pull request #1360 from GWDx/fix-operatorname-number
dpvc Oct 17, 2025
4cf3a3c
Adjust dialog icons for better cross-platform support. Fix dialog he…
dpvc Oct 20, 2025
2ef10bd
Add color handling for dark mode
dpvc Oct 19, 2025
2df9977
Fixes for prettier
dpvc Oct 19, 2025
597dd77
FIx comment typo
dpvc Oct 21, 2025
27c47f3
Merge pull request #1354 from mathjax/update/highlight-enclosures
dpvc Oct 21, 2025
ff85e8d
Update ts/ui/dialog/DraggableDialog.ts
dpvc Oct 21, 2025
9b0d567
Update ts/ui/dialog/DraggableDialog.ts
dpvc Oct 21, 2025
99bd3aa
Merge branch 'develop' into issue3406
dpvc Oct 21, 2025
90691ec
Add more to build instructions for Windows users
dpvc Oct 22, 2025
a0fd588
Add more windows instructions.
dpvc Oct 22, 2025
479a3ce
More updates for windows paths (in asyncLoad, tests, and build)
dpvc Oct 22, 2025
38c4d2d
Update for prettier
dpvc Oct 22, 2025
86225a3
Fix lint issues
dpvc Oct 22, 2025
c1e0c1c
Add missing JSDoc @returns
dpvc Oct 23, 2025
b376402
Only replace mhchem arrows when mhchem versions are available. (math…
dpvc Oct 23, 2025
09f5d2a
Add a fonts loader path and have fonts use that for accessing their d…
dpvc Oct 24, 2025
34355d7
Fixes for prettier
dpvc Oct 24, 2025
dec9d2a
Fixes for prettier
dpvc Oct 24, 2025
436965d
Add move/size toggle keys for use with plain arrows, adjust the help …
dpvc Oct 24, 2025
1135887
Update explorer help to make it clear how to turn off the explorer (f…
dpvc Oct 24, 2025
82eab14
Fix vector arrow positioning for Safari
dpvc Oct 25, 2025
9d2ced3
Fix typo in menu.
dpvc Oct 26, 2025
c13e406
Add missing preLoaded() call for input/mml when a11y is used.
dpvc Oct 26, 2025
b459898
Update spacing for StyleJason for @media rules, and add a test for it
dpvc Oct 26, 2025
e3d534f
Add missing JSDoc parameters
dpvc Oct 26, 2025
90b1d89
Update mhchem tests to include one for check for mhchem arrows
dpvc Oct 26, 2025
0a0f8e5
Update tests to improve coverage of some modules
dpvc Oct 27, 2025
f5429ea
Make the keep-attrs attribute into a property, since it is removed af…
dpvc Oct 27, 2025
a3ad22d
Fix typo in components/bin/build from 479a3ced5
dpvc Oct 28, 2025
a39c43a
Use a default font size when it can't be computed directly (e.g., the…
dpvc Oct 29, 2025
730a405
Prevent a disappearing stretchy arrow in CHTML. (mathjax/MathJax#3457)
dpvc Oct 29, 2025
b66969a
Fix xarrows so that they won't stretch after initial layout. (mathjax…
dpvc Oct 29, 2025
bce7b4b
Update tests for new output for xarrows.
dpvc Oct 29, 2025
9d07173
Fix some issues with data-latex handling and update tests to accommod…
dpvc Nov 2, 2025
1c2529e
Make sure tagName exists before using it. (mathjax/MathJax#3461)
dpvc Nov 4, 2025
85d8430
Make prettier happy
dpvc Nov 4, 2025
62bb93e
Add missing semmi-colon (for prettier)
dpvc Nov 4, 2025
0d5f213
Merge pull request #1375 from mathjax/fix/safari-accents
dpvc Nov 9, 2025
d6c368b
Merge pull request #1376 from mathjax/fix/menu-typo
dpvc Nov 9, 2025
1b9b31d
Merge pull request #1377 from mathjax/fix/mml-preload
dpvc Nov 9, 2025
96e9192
Merge pull request #1378 from mathjax/update/test-coverage
dpvc Nov 9, 2025
ec084b0
Merge pull request #1379 from mathjax/update/keep-attrs
dpvc Nov 9, 2025
6494d56
Remove use of '*' in CSS declarations. (mathjax/MathJax#3463)
dpvc Nov 10, 2025
aeb97d2
Merge pull request #1335 from mathjax/issue3406
dpvc Nov 11, 2025
c9a7e74
Merge pull request #1361 from mathjax/fix/windows-node
dpvc Nov 11, 2025
8c8c5eb
Merge pull request #1371 from mathjax/fix/lint
dpvc Nov 11, 2025
22effae
Merge pull request #1372 from mathjax/issue3452
dpvc Nov 11, 2025
806f2af
Merge pull request #1373 from mathjax/feature/font-path
dpvc Nov 11, 2025
d0510ca
Merge pull request #1380 from mathjax/issue3458
dpvc Nov 11, 2025
c9c6967
Merge pull request #1381 from mathjax/issue3457-stretch
dpvc Nov 11, 2025
ed27170
Merge pull request #1386 from mathjax/issue3461
dpvc Nov 11, 2025
845959a
Merge branch 'develop' into issue3459
dpvc Nov 11, 2025
b6c54a1
Update ts/a11y/explorer/Region.ts
dpvc Nov 13, 2025
ee3e9b4
Merge pull request #1369 from mathjax/feature/dark-mode
dpvc Nov 13, 2025
38cc846
Merge pull request #1382 from mathjax/issue3457-xarrows
dpvc Nov 13, 2025
d098563
Merge pull request #1387 from mathjax/issue3463
dpvc Nov 13, 2025
d3f00dd
Add missing JSDoc, as per review
dpvc Nov 13, 2025
accd304
Merge branch 'develop' into issue3459
dpvc Nov 13, 2025
e8bfee1
Merge pull request #1385 from mathjax/issue3459
dpvc Nov 13, 2025
946a580
Merge branch 'develop' into feature/draggable-dialogs
dpvc Nov 13, 2025
96f6e30
Make assistive-mml unset speech/braille and vice-versa
dpvc Nov 14, 2025
98b3a82
Add localstorage flag needed for node v25
dpvc Nov 14, 2025
1db53db
Add hidden option to retain regions and highlighting, as requested by…
dpvc Nov 16, 2025
d781cfa
Ignore the localstorage file
dpvc Nov 16, 2025
f6715ed
Move colors to CSS and fix problems with magnification of enclosures
dpvc Nov 17, 2025
447f90a
use of node24 for tests and job renaming
zorkow Nov 19, 2025
a634d43
Merge pull request #1390 from mathjax/feature/keep-regions
dpvc Nov 20, 2025
fecee0a
Merge pull request #1357 from mathjax/feature/draggable-dialogs
dpvc Nov 20, 2025
685a53b
Merge pull request #1389 from mathjax/fix/node-25
dpvc Nov 20, 2025
671b673
Add noRerender() function, as request in review
dpvc Nov 20, 2025
7e1618d
Add more information to the help dialog about hidden MathML.
dpvc Nov 20, 2025
1a65c63
Merge branch 'develop' into update/assistive-mml
dpvc Nov 20, 2025
5f3b73b
Fix formatting
dpvc Nov 20, 2025
c084317
Fix indentation.
dpvc Nov 20, 2025
cb2c67a
Merge branch 'develop' into update/tools
zorkow Nov 28, 2025
6e61db2
ensure cl-lib is loaded for jest diff tools
zorkow Nov 28, 2025
c716141
update copyright
zorkow Nov 28, 2025
a5f845b
Make sure width is a string before using match()
dpvc Dec 1, 2025
e3bf19e
Merge pull request #1393 from mathjax/update/tools
zorkow Dec 2, 2025
428272b
Merge pull request #1388 from mathjax/update/assistive-mml
dpvc Dec 6, 2025
a14d976
Merge pull request #1394 from mathjax/fix/mpadded
dpvc Dec 6, 2025
2419bfc
Update ts/a11y/explorer/Region.ts
dpvc Dec 6, 2025
61721ef
Fix problems with SVG magnification of expressions with tags, and wit…
dpvc Dec 7, 2025
ab6a5c9
Make sure the Braille for the top-level expression is transfered to t…
dpvc Nov 17, 2025
733a5cf
Hide brailleSpeech menu option and add information about Braille outp…
dpvc Nov 19, 2025
4ef32a6
Remove commented-out code
dpvc Dec 7, 2025
cf81423
Fixes for prettier
dpvc Dec 7, 2025
49d8b61
Use cjs for node-main-setup so it works in bun as well as node. (math…
dpvc Dec 8, 2025
86d5722
Merge pull request #1391 from mathjax/update/css-colors
dpvc Dec 9, 2025
dc349f9
Merge pull request #1397 from mathjax/issue3476
dpvc Dec 10, 2025
5e72070
update SRE to version 5-beta.2
zorkow Dec 10, 2025
d89a4c0
Add help information (again), hide the replace-speech menu (again), …
dpvc Dec 11, 2025
6663405
Add 'b' key to toggle the Braille 'Combine with Speech' option
dpvc Dec 11, 2025
af44f98
Merge pull request #1396 from mathjax/fix/braille
dpvc Dec 11, 2025
26ead54
upgrades to SRE v5-beta.3
zorkow Dec 14, 2025
d8d8fc4
Fix position of inline help icon caused by changes in #1350
dpvc Dec 15, 2025
09bec73
Merge pull request #1400 from mathjax/fix/inline-icon
dpvc Dec 15, 2025
630568a
Merge pull request #1398 from mathjax/update/sre
dpvc Dec 15, 2025
f7b439b
Update version to 4.1.0
dpvc Dec 15, 2025
3e932d8
Update font and menu dependencies
dpvc Dec 15, 2025
f51dc07
Update dev dependencies
dpvc Dec 15, 2025
82cabf4
Update formatting for prettier
dpvc Dec 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
types: [published]

jobs:
setup:
publish:
runs-on: ubuntu-latest
name: Build and publish MathJax
permissions:
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
- develop

jobs:
setup:
testing:
runs-on: ubuntu-latest
name: Compile and test MathJax
steps:
Expand All @@ -22,6 +22,12 @@ jobs:
version: 10
run_install: false

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 24
cache: 'pnpm'

- name: Install packages
run: |
pnpm -r i
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ coverage
/bundle
/bundle-cjs
/testsuite/js
/testsuite/lib/localstorage
/lab/sre.js
30 changes: 29 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,35 @@ npm run --silent build-all
```

in order to compile the JavaScript files from the TypeScript source,
and build the component files from the JavaScript files.
and build the component files from the JavaScript files. Windows
users will need to use the command

``` bash
npm config set script-shell "C:\\Program Files\\Git\\bin\\bash.exe"
```

first in order to tell `pnpm` to use the `bash` shell for scripts that
it runs, as that is required by the build scripts that MathJax defines
in the `package.json` file. You may also need to use

``` bash
Set-ExecutionPolicy Unrestricted
```

to allow the scripts to run, if you receive errors about not being
able to run the scripts.

The build process requires MathJax to set up a symbolic link, and in
Windows, that requires permission, so you may receive an error message
to that effect. If so, you may need to run

``` bash
pnpm link:src
```

from a shell with administrator privileges. Once that is done, you
can run the build process from a non-administrator shell.


## Code Contributions

Expand Down
30 changes: 20 additions & 10 deletions components/bin/build
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ process.chdir(path.dirname(json));
const mjPath = path.relative(process.cwd(), path.resolve(__dirname, '..', '..', target));
const mjGlobal = path.join('..', mjPath, 'components', 'global.js');

/**
* Determine the module type
*/
function getType() {
const component = config.component || 'part';
if (component.match(/\/(svg|chtml|common)\/fonts\//)) return RegExp.$1 + '-font';
Expand All @@ -69,6 +72,13 @@ function getType() {
return component;
}

/**
* Convert Windows paths to unix paths
*/
const normalize = process.platform === 'win32'
? (file) => file.replace(/\\/g, '/')
: (file) => file;

/**
* Extract the configuration values
*/
Expand Down Expand Up @@ -100,7 +110,7 @@ let PACKAGE = [];
*/
function processList(base, dir, list, top = true) {
for (const item of list) {
const file = path.join(dir, item);
const file = normalize(path.join(dir, item));
if (!EXCLUDE.has(file)) {
const stat = fs.statSync(path.resolve(base, file));
if (stat.isDirectory()) {
Expand Down Expand Up @@ -183,9 +193,9 @@ function processParts(parts) {
function processLines(file, objects) {
if (objects.length === 0) return [];
const base = path.dirname(file).replace(/^\.$/, '');
const dir = (PREFIX ? path.join(PREFIX, base) : base);
const dir = (PREFIX ? normalize(path.join(PREFIX, base)) : base);
const dots = dir.replace(/[^\/]+/g, '..') || '.';
const relative = path.join(dots, '..', JS, dir, path.basename(file)).replace(/\.ts$/, '.js');
const relative = normalize(path.join(dots, '..', JS, dir, path.basename(file))).replace(/\.ts$/, '.js');
const name = path.parse(file).name;
const lines = (target === 'mjs' ? [] : [
'"use strict";',
Expand Down Expand Up @@ -254,7 +264,7 @@ function getExtraDirectories() {
let prefix = '';
let indent = INDENT;
let postfix = '';
for (let name of PREFIX.split(/\//)) {
for (let name of PREFIX.split('/')) {
if (name.match(/[^a-zA-Z0-9]/)) {
name = `"${name}"`;
}
Expand All @@ -271,19 +281,19 @@ function getExtraDirectories() {
function processGlobal() {
console.info(' ' + COMPONENT + '.ts');
const lines = (target === 'cjs' ? [
`const {combineWithMathJax} = require('${GLOBAL}')`,
`const {VERSION} = require('${VERSION}');`,
`const {combineWithMathJax} = require('${normalize(GLOBAL)}')`,
`const {VERSION} = require('${normalize(VERSION)}');`,
'',
] : [
`import {combineWithMathJax} from '${GLOBAL}';`,
`import {VERSION} from '${VERSION}';`,
`import {combineWithMathJax} from '${normalize(GLOBAL)}';`,
`import {VERSION} from '${normalize(VERSION)}';`,
'',
]);
const [prefix, indent, postfix] = getExtraDirectories();
const packages = [];
PACKAGE = PACKAGE.sort(sortDir);
while (PACKAGE.length) {
const dir = path.dirname(PACKAGE[0]).split(path.sep)[0];
const dir = path.dirname(PACKAGE[0]).split('/')[0];
packages.push(processPackage(lines, indent, dir));
}
const name = (ID.match(/[^a-zA-Z0-9_]/) ? `"${ID}"` : ID);
Expand Down Expand Up @@ -337,7 +347,7 @@ function processPackage(lines, space, dir) {
if (path.dirname(PACKAGE[0]) === dir) {
const file = PACKAGE.shift();
const name = path.basename(file);
let relativefile = path.join('..', JS, dir, name).replace(/\.ts$/, '.js')
const relativefile = normalize(path.join('..', JS, dir, name).replace(/\.ts$/, '.js'));
const component = 'module' + (++importCount);
lines.push(
target === 'cjs' ?
Expand Down
9 changes: 8 additions & 1 deletion components/bin/makeAll
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ function fileRegExp(name) {
return new RegExp(name.replace(/([\\.{}[\]()?*^$])/g, '\\$1'), 'g');
}

/**
* Options for the execSync() function
*/
const execOptions = process.platform === 'win32'
? { shell: `${process.env.ProgramFiles}\\Git\\bin\\bash.exe` }
: {};

/**
* Get the current working directory
*/
Expand Down Expand Up @@ -196,7 +203,7 @@ function processSubdirs(dir, action, config) {
* Run a command on a given directory
*/
function run(cmd, dir) {
return execSync(cmd + ` '${path.relative('.', dir).replace(/'/g, '\\\'')}'`);
return execSync(cmd + ` '${path.relative('.', dir).replace(/'/g, '\\\'')}'`, execOptions);
}

/**
Expand Down
30 changes: 16 additions & 14 deletions components/bin/pack
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

const fs = require('fs');
const path = require('path');
const {spawn, execSync} = require('child_process');
const {spawn} = require('child_process');

/**
* The module type to use ('cjs' or 'mjs')
Expand Down Expand Up @@ -64,14 +64,7 @@ const rootRE = fileRegExp(path.dirname(jsPath));
const nodeRE = /^.*\/node_modules/;
const fontRE = new RegExp('^.*\\/(mathjax-[^\/-]*)(?:-font)?\/(build|[cm]js)');

/**
* Find the directory where npx runs (so we know where "npx webpack" will run)
* (We use npx rather than pnpm here as it seems that pnpm doesn't
* find the executable from a node_modules directory higher than the
* first package.json, and extensions and fonts can have their own
* package.json.)
*/
const packDir = String(execSync('npx node -e "console.log(process.cwd())"'));
const packDir = process.cwd();

/**
* @param {string} dir The directory to pack
Expand All @@ -80,11 +73,20 @@ const packDir = String(execSync('npx node -e "console.log(process.cwd())"'));
async function readJSON(dir) {
return new Promise((ok, fail) => {
const buffer = [];
const child = spawn('npx', [
'webpack', '--env', `dir=${path.relative(packDir, path.resolve(dir))}`,
'--env', `bundle=${bundle}`, '--json',
'-c', path.relative(packDir, path.join(compPath, 'webpack.config.' + target))
]);
const child = spawn(
'npx',
[
'webpack',
'--env', `dir=${path.relative(packDir, path.resolve(dir))}`,
'--env', `bundle=${bundle}`,
'--json',
'-c', path.relative(packDir, path.join(compPath, 'webpack.config.' + target))
],
{
cwd: packDir,
shell: true,
}
);
child.stdout.on('data', (data) => buffer.push(String(data)));
child.stderr.on('data', (data) => console.error(String(data)));
child.on('close', (code) => {
Expand Down
8 changes: 4 additions & 4 deletions components/mjs/a11y/speech/speech.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ import './lib/speech.js';

import {combineDefaults} from '#js/components/global.js';
import {Package} from '#js/components/package.js';
import {hasWindow} from '#js/util/context.js';
import {context} from '#js/util/context.js';
import {SpeechHandler} from '#js/a11y/speech.js';

if (MathJax.loader) {
let path = Package.resolvePath('[sre]', false);
let maps = Package.resolvePath('[mathmaps]', false);
if (hasWindow) {
if (context.window) {
path = new URL(path, location).href;
maps = new URL(maps, location).href;
} else {
const REQUIRE = typeof require !== 'undefined' ? require : MathJax.config.loader.require;
if (REQUIRE?.resolve) {
path = REQUIRE.resolve(`${path}/require.mjs`).replace(/\/[^\/]*$/, '');
maps = REQUIRE.resolve(`${maps}/base.json`).replace(/\/[^\/]*$/, '');
path = context.path(REQUIRE.resolve(`${path}/require.mjs`)).replace(/\/[^\/]*$/, '');
maps = context.path(REQUIRE.resolve(`${maps}/base.json`)).replace(/\/[^\/]*$/, '');
} else {
path = maps = '';
}
Expand Down
3 changes: 2 additions & 1 deletion components/mjs/a11y/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ Loader.preLoaded(
'a11y/sre',
'a11y/semantic-enrich',
'a11y/speech',
'a11y/explorer'
'a11y/explorer',
'input/mml',
);
2 changes: 2 additions & 0 deletions components/mjs/core/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"targets": [
"mathjax.ts",
"core", "util", "handlers",
"ui/dialog/DraggableDialog.ts",
"ui/dialog/InfoDialog.ts",
"adaptors/HTMLAdaptor.ts",
"adaptors/browserAdaptor.ts",
"components/global.ts"
Expand Down
10 changes: 5 additions & 5 deletions components/mjs/input/tex/extension.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {combineDefaults} from '#js/components/global.js';
import {hasWindow} from '#js/util/context.js';

export function fontExtension(id, name, pkg = `@mathjax/${name}`) {
export function fontExtension(id, name, pkg = `[fonts]/${name}`) {
if (MathJax.loader) {
const FONTPATH = hasWindow ? `https://cdn.jsdelivr.net/npm/${pkg}` : pkg;
const path = name.replace(/-font-extension$/, '-extension');
const jax = (MathJax.config?.startup?.output || 'chtml');
combineDefaults(MathJax.config.loader, 'paths', {[path]: FONTPATH});
combineDefaults(MathJax.config.loader, 'dependencies', {[`[${path}]/${jax}`]: [`output/${jax}`]});
combineDefaults(MathJax.config.loader, 'paths', {[path]: pkg});
if (!MathJax._.output?.[jax]) {
combineDefaults(MathJax.config.loader, 'dependencies', {[`[${path}]/${jax}`]: [`output/${jax}`]});
}
MathJax.loader.addPackageData(id, {
extraLoads: [`[${path}]/${jax}`],
rendererExtensions: [path]
Expand Down
2 changes: 1 addition & 1 deletion components/mjs/node-main/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"copy": [
"node-main.mjs",
"node-main.cjs",
"node-main-setup.mjs"
"node-main-setup.cjs"
]
},
"webpack": {
Expand Down
5 changes: 5 additions & 0 deletions components/mjs/node-main/node-main-setup.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
global.require = require;
const path = require("path");

if (!global.MathJax) global.MathJax = {};
global.MathJax.__dirname = __dirname;
7 changes: 0 additions & 7 deletions components/mjs/node-main/node-main-setup.mjs

This file was deleted.

3 changes: 2 additions & 1 deletion components/mjs/node-main/node-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ import '../startup/init.js';
import {Loader, CONFIG} from '#js/components/loader.js';
import {Package} from '#js/components/package.js';
import {combineDefaults, combineConfig} from '#js/components/global.js';
import {context} from '#js/util/context.js';
import '../core/core.js';
import '../adaptors/liteDOM/liteDOM.js';
import {source} from '../source.js';

const MathJax = global.MathJax;

const path = eval('require("path")'); // get path from node, not webpack
const dir = MathJax.config.__dirname; // set up by node-main.mjs or node-main.cjs
const dir = context.path(MathJax.config.__dirname); // set up by node-main.mjs or node-main.cjs

/*
* Set up the initial configuration
Expand Down
2 changes: 1 addition & 1 deletion components/mjs/node-main/node-main.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import './node-main-setup.mjs';
import './node-main-setup.cjs';
import {MathJax} from './node-main.js';
export default MathJax;
export const init = MathJax.init;
34 changes: 25 additions & 9 deletions components/mjs/output/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,25 @@ import {combineDefaults, combineWithMathJax} from '#js/components/global.js';
import {Package} from '#js/components/package.js';
import {hasWindow} from '#js/util/context.js';

export const FONTPATH = hasWindow ?
'https://cdn.jsdelivr.net/npm/@mathjax/%%FONT%%-font':
'@mathjax/%%FONT%%-font';
export function configFont(font, jax, config, extension = '') {
const path = (config.fontPath || `[fonts]/%%FONT%%-font${extension}`);
const name = (font.match(/^[a-z]+:/) ? (font.match(/[^/:\\]*$/) || [jax])[0] : font);
combineDefaults(MathJax.config.loader, 'paths', {
[name+extension]: (name === font ? path.replace(/%%FONT%%/g, font) : font)
});
return `[${name}${extension}]`;
}

export function configExtensions(jax, config) {
const extensions = [];
for (const name of (config.fontExtensions || [])) {
const font = configFont(name, jax, config, '-extension');
const module = `${font}/${jax}`
extensions.push(module);
}
return extensions;
}

export const OutputUtil = {
config(jax, jaxClass, defaultFont, fontClass) {

Expand All @@ -20,15 +36,15 @@ export const OutputUtil = {
}

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

const extensions = configExtensions(jax, config);
if (extensions.length) {
MathJax.loader.addPackageData(`${font}/${jax}`, {extraLoads: extensions});
}

if (name !== defaultFont || !fontClass) {

MathJax.loader.addPackageData(`output/${jax}`, {extraLoads: [`${font}/${jax}`]});
Expand Down
2 changes: 1 addition & 1 deletion components/mjs/source-lab.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
* limitations under the License.
*/

export const src = String(new URL('.', import.meta.url)).replace(/\/$/, '');
export const dirname = String(new URL('.', import.meta.url)).replace(/\/$/, '');
Loading