Skip to content
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

Prevent file system paths from being included in mml3 extension. #993

Merged
merged 1 commit into from
Sep 15, 2023
Merged
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
1 change: 0 additions & 1 deletion components/bin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"#js/*": "mathjax-full/cjs/*",
"#source/*": "mathjax-full/components/cjs/*",
"#root/*": "mathjax-full/cjs/components/cjs/*",
"#mml3/*": "mathjax-full/cjs/input/mathml/mml3/cjs/*",
"#menu/*": "mj-context-menu/cjs/*",
"#sre/*": "speech-rule-engine/cjs/*",
"#mhchem/*": "mhchemparser/dist/*",
Expand Down
6 changes: 4 additions & 2 deletions components/root-pack.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//
// Do what __dirname does in webpack
// Replacement for __dirname for root directory
//
export const esRoot = () => '/';

const config = global.MathJax?.config || {};
export const mjxRoot = () => config?.loader?.paths?.mathjax || config?.__dirname || '/';
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
"#js/*": "mathjax-full/mjs/*",
"#source/*": "mathjax-full/components/mjs/*",
"#root/*": "mathjax-full/mjs/components/mjs/*",
"#mml3/*": "mathjax-full/mjs/input/mathml/mml3/mjs/*",
"#menu/*": "mj-context-menu/js/*",
"#sre/*": "speech-rule-engine/js/*",
"#mhchem/*": "mhchemparser/esm/*",
Expand Down Expand Up @@ -110,9 +109,9 @@
"build": "npm run -s build-mjs",
"build-all": "npm run -s build-mjs ; echo ; npm run -s build-cjs",
"=============================================================================== mml3": "",
"premake-mml3-xslt": "cd ts/input/mathml/mml3 && grep '^\\s*\\(<\\|or\\|xmlns\\|excl\\|\">\\)' mml3.ts > mml3.xsl",
"make-mml3-xslt": "cd ts/input/mathml/mml3 && npx xslt3 -t -xsl:mml3.xsl -export:mml3.sef.json -nogo",
"postmake-mml3-xslt": "npx rimraf ts/input/mathml/mml3/mml3.xsl",
"premake-mml3-xslt": "grep '^\\s*\\(<\\|or\\|xmlns\\|excl\\|\">\\)' ts/input/mathml/mml3/mml3.ts > /tmp/mml3.xsl",
"make-mml3-xslt": "npx xslt3 -t -xsl:/tmp/mml3.xsl -export:ts/input/mathml/mml3/mml3.sef.json -nogo",
"postmake-mml3-xslt": "npx rimraf /tmp/mml3.xsl",
"=============================================================================== install": "",
"link:full": "node components/bin/link-full",
"install": "npm run -s link:full",
Expand Down
2 changes: 1 addition & 1 deletion ts/components/cjs/root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ declare const __dirname: string;
/**
* @return {string} The MathJax component root directory
*/
export function esRoot(): string {
export function mjxRoot(): string {
return __dirname.replace(/[cm]js\/components\/[cm]js$/, (_) => 'bundle');
}
4 changes: 2 additions & 2 deletions ts/components/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {MathJax as MJGlobal, MathJaxObject as MJObject, MathJaxLibrary,
MathJaxConfig as MJConfig, combineWithMathJax, combineDefaults} from './global.js';
import {Package, PackageError, PackageReady, PackageFailed} from './package.js';
import {FunctionList} from '../util/FunctionList.js';
import {esRoot} from '#root/root.js';
import {mjxRoot} from '#root/root.js';

/*
* The browser document (if any)
Expand Down Expand Up @@ -220,7 +220,7 @@ export namespace Loader {
return (script as HTMLScriptElement).src.replace(/\/[^\/]*$/, '');
}
}
return esRoot();
return mjxRoot();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion ts/components/mjs/root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
/**
* @return {string} The MathJax component root directory
*/
export function esRoot(): string {
export function mjxRoot(): string {
return new URL(import.meta.url).pathname
.replace(/[cm]js\/components\/[cm]js\/root.js$/, (_) => 'bundle');
}
Expand Down
32 changes: 0 additions & 32 deletions ts/input/mathml/mml3/cjs/xsltFilename.ts

This file was deleted.

32 changes: 0 additions & 32 deletions ts/input/mathml/mml3/mjs/xsltFilename.ts

This file was deleted.

7 changes: 5 additions & 2 deletions ts/input/mathml/mml3/mml3-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/

import {MathDocument} from '../../../core/MathDocument.js';
import {xsltFilename} from '#mml3/xsltFilename.js';
import {mjxRoot} from '#root/root.js';

/**
* Create the transform function that uses Saxon-js to perform the
Expand All @@ -44,7 +44,10 @@ export function createTransform<N, T, D>(): (node: N, doc: MathDocument<N, T, D>
}
const Saxon = nodeRequire('saxon-js'); // dynamically load Saxon-JS.
const path = nodeRequire('path'); // use the real version from node.
const xslt = nodeRequire(xsltFilename(path)); // load the preprocessed stylesheet.
//
// Load the XSLT stylesheet
//
const xslt = nodeRequire(path.resolve(mjxRoot(), 'input', 'mml', 'extensions', 'mml3.sef.json'));
return (node: N, doc: MathDocument<N, T, D>) => {
const adaptor = doc.adaptor;
let mml = adaptor.outerHTML(node);
Expand Down
2 changes: 1 addition & 1 deletion ts/input/mathml/mml3/mml3.sef.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion tsconfig/cjs.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"#js/*": ["../cjs/*"],
"#source/*": ["../components/cjs/*"],
"#root/*": ["../ts/components/cjs/*"],
"#mml3/*": ["../ts/input/mathml/mml3/cjs/*"],
"#menu/*": ["../node_modules/mj-context-menu/cjs/*"],
"#sre/*": ["../node_modules/speech-rule-engine/cjs/*"],
"#mhchem/*": ["../node_modules/mhchemparser/dist/*"],
Expand Down
1 change: 0 additions & 1 deletion tsconfig/mjs.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"#js/*": ["../mjs/*"],
"#source/*": ["../components/mjs/*"],
"#root/*": ["../ts/components/mjs/*"],
"#mml3/*": ["../ts/input/mathml/mml3/mjs/*"],
"#menu/*": ["../node_modules/mj-context-menu/js/*"],
"#sre/*": ["../node_modules/speech-rule-engine/js/*"],
"#mhchem/*": ["../node_modules/mhchemparser/esm/*"],
Expand Down