From f03e918351f6ba05e1a3f31e3be06ac832f4b174 Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Tue, 25 Mar 2025 09:02:12 -0400 Subject: [PATCH 1/8] Update assistive MathML styles --- ts/a11y/assistive-mml.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/ts/a11y/assistive-mml.ts b/ts/a11y/assistive-mml.ts index 79ee8c19c..cb1c147f3 100644 --- a/ts/a11y/assistive-mml.ts +++ b/ts/a11y/assistive-mml.ts @@ -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 */ From b7f194201f26e19d41bbcc392a33a11a21a66e0d Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Sat, 19 Apr 2025 07:42:10 -0400 Subject: [PATCH 2/8] Make sure speech-workerpool doesn't give a version error --- ts/adaptors/lite/Element.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/ts/adaptors/lite/Element.ts b/ts/adaptors/lite/Element.ts index feff446ae..8037a3508 100644 --- a/ts/adaptors/lite/Element.ts +++ b/ts/adaptors/lite/Element.ts @@ -28,6 +28,10 @@ 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 @@ -168,9 +172,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, From 1b277c8ed8e7367eec6c1f8db3fa4d5e2a585d31 Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Sat, 19 Apr 2025 07:43:00 -0400 Subject: [PATCH 3/8] Make sure the result is available when require() is used --- ts/components/package.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/ts/components/package.ts b/ts/components/package.ts index d0326c5b2..0572978eb 100644 --- a/ts/components/package.ts +++ b/ts/components/package.ts @@ -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) { From e62d94952f6eb30fee4f9e0b53dc2c4e0d3bad3e Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Fri, 25 Apr 2025 09:55:06 -0400 Subject: [PATCH 4/8] Add a MathJax.whenReady() method --- ts/components/startup.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ts/components/startup.ts b/ts/components/startup.ts index 6f296286c..e83a6f115 100644 --- a/ts/components/startup.ts +++ b/ts/components/startup.ts @@ -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) { @@ -393,6 +394,8 @@ export abstract class Startup { } } MathJax.done = () => Startup.document.done(); + MathJax.whenReady = (action: () => any) => + Startup.document.whenReady(action); } /** From c0dc9ae7535a2dae450e3c4e5018a644ff37e68d Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Sat, 19 Apr 2025 07:44:03 -0400 Subject: [PATCH 5/8] Prevent a failure when the menu component isn't loaded --- ts/input/tex/require/RequireConfiguration.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ts/input/tex/require/RequireConfiguration.ts b/ts/input/tex/require/RequireConfiguration.ts index 7f05fd0c5..dc539eae3 100644 --- a/ts/input/tex/require/RequireConfiguration.ts +++ b/ts/input/tex/require/RequireConfiguration.ts @@ -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); } From 891660ab114d25d53478dcb3be2653a759342241 Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Fri, 25 Apr 2025 09:56:15 -0400 Subject: [PATCH 6/8] Work around placement bug for elements in WebKit --- ts/output/chtml/Wrappers/mmultiscripts.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ts/output/chtml/Wrappers/mmultiscripts.ts b/ts/output/chtml/Wrappers/mmultiscripts.ts index e35fcd786..a94d86b61 100644 --- a/ts/output/chtml/Wrappers/mmultiscripts.ts +++ b/ts/output/chtml/Wrappers/mmultiscripts.ts @@ -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', + }, }; /*************************************************************/ From f4383cfd5c34829c57888358ca6a4df9982c42d9 Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Fri, 28 Feb 2025 10:58:53 -0500 Subject: [PATCH 7/8] Handle processing of extensions and fonts better --- components/bin/makeAll | 3 +-- components/bin/pack | 27 +++++++++++++++++---------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/components/bin/makeAll b/components/bin/makeAll index ced43347a..fb32d1153 100755 --- a/components/bin/makeAll +++ b/components/bin/makeAll @@ -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 diff --git a/components/bin/pack b/components/bin/pack index 30797693c..66534975f 100755 --- a/components/bin/pack +++ b/components/bin/pack @@ -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') @@ -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'); } /** @@ -59,14 +57,22 @@ 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 @@ -74,9 +80,10 @@ const fontRE = new RegExp('^.*\\/(mathjax-[^\/-]*)(?:-font)?\/(build|[cm]js)'); 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))); From f672ef46bbc22b0b82135b61ea9c2862a6a4cfba Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Fri, 25 Apr 2025 09:59:06 -0400 Subject: [PATCH 8/8] Prettier fix --- ts/adaptors/lite/Element.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/ts/adaptors/lite/Element.ts b/ts/adaptors/lite/Element.ts index 8037a3508..31e527b86 100644 --- a/ts/adaptors/lite/Element.ts +++ b/ts/adaptors/lite/Element.ts @@ -30,7 +30,6 @@ import { LiteWindow } from './Window.js'; import { asyncLoad } from '../../util/AsyncLoad.js'; import { mathjax } from '../../mathjax.js'; - declare const MathJax: any; /**