Skip to content

Misc fixes #1244

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 1 addition & 2 deletions components/bin/makeAll
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,9 @@ function fileRegExp(name) {
}

/**
* Get and change the current working directory
* Get the current working directory
*/
const root = process.cwd();
process.chdir(path.dirname(path.dirname(__dirname)));

/**
* Regular expression for the components directory
Expand Down
27 changes: 17 additions & 10 deletions components/bin/pack
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@
* @author dpvc@mathjax.org (Davide Cervone)
*/


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

/**
* The module type to use ('cjs' or 'mjs')
Expand All @@ -40,11 +39,10 @@ const bundle = (process.argv[3] || 'bundle');

/**
* @param {string} name The file name to turn into a Regular expression
* @param {string} tail Additional regexp to include after the file path
* @return {RegExp} The regular expression for the name,
*/
function fileRegExp(name, tail = '') {
return new RegExp(name.replace(/([\\.{}[\]()?*^$])/g, '\\$1') + tail, 'g');
function fileRegExp(name) {
return new RegExp(name.replace(/([\\.{}[\]()?*^$])/g, '\\$1'), 'g');
}

/**
Expand All @@ -59,24 +57,33 @@ function fileSize(file) {
* Regular expressions for the components directory and the MathJax .js location
*/
const compPath = path.dirname(__dirname);
const nodePath = path.join(__dirname, '..', '..', 'node_modules');
const mjPath = path.dirname(compPath);
const jsPath = path.join(__dirname, '..', '..', target);
const compRE = fileRegExp(compPath);
const rootRE = fileRegExp(path.dirname(jsPath));
const nodeRE = fileRegExp(nodePath, '(?:/\\.pnpm/.*?/node_modules)?');
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())"'));

/**
* @param {string} dir The directory to pack
* @return {JSON} The parsed JSON from webpack
*/
async function readJSON(dir) {
return new Promise((ok, fail) => {
const buffer = [];
const child = spawn('pnpm', [
'webpack', '--env', `dir=${dir}`, '--env', `bundle=${bundle}`, '--json',
'-c', path.relative('.', 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))
]);
child.stdout.on('data', (data) => buffer.push(String(data)));
child.stderr.on('data', (data) => console.error(String(data)));
Expand Down
1 change: 1 addition & 0 deletions ts/a11y/assistive-mml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ export function AssistiveMmlMathDocumentMixin<
display: 'block !important',
width: 'auto !important',
overflow: 'hidden !important',
'text-indent': '0px ! important',
/*
* Don't allow the assistive MathML to become part of the selection
*/
Expand Down
11 changes: 8 additions & 3 deletions ts/adaptors/lite/Element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ import { LiteDocument } from './Document.js';
import { LiteWindow } from './Window.js';

import { asyncLoad } from '../../util/AsyncLoad.js';
import { mathjax } from '../../mathjax.js';

declare const MathJax: any;

/**
* A minimal webworker interface
Expand Down Expand Up @@ -168,9 +171,11 @@ export class LiteIFrame extends LiteElement {
`${this.options.path}/${this.options.worker}`,
this.options.debug,
];
const { WorkerPool, setContext } = await asyncLoad(
`${this.options.path}/speech-workerpool.js`
);
const pool = `${this.options.path}/speech-workerpool.js`;
if (MathJax?.loader) {
MathJax.loader.versions.set(pool, mathjax.version);
}
const { WorkerPool, setContext } = await asyncLoad(pool);
setContext({
Worker: LiteWorker,
window: this.contentWindow,
Expand Down
1 change: 1 addition & 0 deletions ts/components/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ export class Package {
this.failed('Can\'t load "' + url + '"\n' + err.message.trim())
);
} else {
this.result = result;
this.checkLoad();
}
} catch (err) {
Expand Down
3 changes: 3 additions & 0 deletions ts/components/startup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ export abstract class Startup {
* If there is a registered output jax
* Make input2output() and input2outputPromise conversion methods and outputStylesheet() method
* Create the MathJax.done() method.
* Create the MathJax.whenReady() method.
*/
public static makeMethods() {
if (Startup.input && Startup.output) {
Expand All @@ -393,6 +394,8 @@ export abstract class Startup {
}
}
MathJax.done = () => Startup.document.done();
MathJax.whenReady = (action: () => any) =>
Startup.document.whenReady(action);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion ts/input/tex/require/RequireConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export function RequireLoad(parser: TexParser, name: string) {
mathjax.retryAfter(Loader.load(extension));
}
const require = LOADERCONFIG[extension]?.rendererExtensions;
const menu = (MathJax.startup.document as MenuMathDocument).menu;
const menu = (MathJax.startup.document as MenuMathDocument)?.menu;
if (require && menu) {
menu.addRequiredExtensions(require);
}
Expand Down
7 changes: 7 additions & 0 deletions ts/output/chtml/Wrappers/mmultiscripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,13 @@ export const ChtmlMmultiscripts = (function <
'[script-align="right"] > mjx-row > mjx-cell': {
'text-align': 'right',
},
//
// This declaration avoids a Safari positioning bug:
//
'mjx-none': {
display: 'inline-block',
height: '1px',
},
};

/*************************************************************/
Expand Down