|
1 | 1 | import {combineDefaults} from '#js/components/global.js'; |
2 | 2 |
|
3 | 3 | export function fontExtension(id, name, pkg = `@mathjax/${name}`) { |
4 | | - if (MathJax.config?.loader) { |
5 | | - const FONTPATH = (typeof document === 'undefined' ? pkg : |
6 | | - `https://cdn.jsdelivr.net/npm/${name}`); |
| 4 | + if (MathJax.loader) { |
| 5 | + const FONTPATH = (typeof document === 'undefined' ? pkg : `https://cdn.jsdelivr.net/npm/${name}`); |
7 | 6 | const path = name.replace(/-font-extension$/, '-extension'); |
8 | 7 | const extension = name.replace(/-font-extension$/, ''); |
| 8 | + const jax = (MathJax.config?.startup?.output || 'chtml'); |
9 | 9 | combineDefaults(MathJax.config.loader, 'paths', {[path]: FONTPATH}); |
10 | | - combineDefaults(MathJax.config.loader, 'dependencies', { |
11 | | - [`[${path}]/chtml`]: ['output/chtml'], |
12 | | - [`[${path}]/svg`]: ['output/svg'] |
| 10 | + combineDefaults(MathJax.config.loader, 'dependencies', {[`[${path}]/${jax}`]: [`output/${jax}`]}); |
| 11 | + MathJax.loader.addPackageData(id, { |
| 12 | + extraLoads: [`[${path}]/${jax}`], |
| 13 | + rendererExtensions: [path] |
13 | 14 | }); |
14 | | - MathJax.config.loader[id] = { |
15 | | - checkReady() { |
16 | | - return MathJax.loader.load( |
17 | | - `[${path}]/${MathJax.config?.startup?.output || 'chtml'}` |
18 | | - ).then(() => { |
19 | | - MathJax.startup.document?.outputJax?.addExtension(extension); |
20 | | - }); |
21 | | - } |
22 | | - }; |
23 | 15 | } |
24 | 16 | } |
0 commit comments