@vmz/plugin-mathjax 0.0.2 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +8 -5
  2. package/package.json +8 -3
  3. package/runtime.ts +24 -9
package/README.md CHANGED
@@ -5,6 +5,8 @@
5
5
  `@vmz/plugin-mathjax` connects MathJax to VMZ for applications whose mathematical content needs deeper TeX coverage,
6
6
  richer notation, or compatibility with existing scholarly material.
7
7
 
8
+ Peer dependency: `@mathjax/src` **v4+** (replaces deprecated `mathjax-full`).
9
+
8
10
  ## The tradeoff
9
11
 
10
12
  MathJax is the capability-first choice. It can handle cases that a lightweight typesetter may not, but it carries a
@@ -23,9 +25,10 @@ Think of MathJax as the right specialist tool when formula fidelity is worth a h
23
25
  - Documentation that cannot accept a smaller supported syntax surface.
24
26
  - Mathematical publishing that depends on the broader MathJax ecosystem.
25
27
 
26
- | Product priority | Better starting point |
27
- |---|---|
28
- | Fast common formulas and compact delivery | KaTeX |
29
- | Broad TeX compatibility and specialist content | MathJax |
28
+ | Product priority | Better starting point |
29
+ |------------------------------------------------|-----------------------|
30
+ | Fast common formulas and compact delivery | KaTeX |
31
+ | Broad TeX compatibility and specialist content | MathJax |
30
32
 
31
- The choice remains local to mathematical presentation. It does not force a different VMZ routing, state, testing, or deployment model.
33
+ The choice remains local to mathematical presentation. It does not force a different VMZ routing, state, testing, or
34
+ deployment model.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vmz/plugin-mathjax",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "type": "module",
5
5
  "description": "VMZ MathJax adapter - <Mathjax> + math engine",
6
6
  "license": "MIT",
@@ -17,10 +17,15 @@
17
17
  }
18
18
  },
19
19
  "dependencies": {
20
- "@vmz/plugin": "0.0.2"
20
+ "@vmz/plugin": "0.0.4"
21
21
  },
22
22
  "peerDependencies": {
23
- "mathjax-full": ">=3"
23
+ "@mathjax/src": ">=4"
24
+ },
25
+ "peerDependenciesMeta": {
26
+ "@mathjax/src": {
27
+ "optional": false
28
+ }
24
29
  },
25
30
  "keywords": [
26
31
  "vmz",
package/runtime.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * MathJax TeX HTML/SVG helper.
2
+ * MathJax TeX -> SVG helper (MathJax v4 / `@mathjax/src`).
3
3
  * Prefer KaTeX for common docs; MathJax for heavier TeX coverage.
4
4
  */
5
5
 
@@ -7,21 +7,36 @@ type TexConvert = (tex: string, display: boolean) => string;
7
7
 
8
8
  let tex2svg: TexConvert | null = null;
9
9
 
10
+ const EM = 16;
11
+ const EX = 8;
12
+
10
13
  async function getConvert(): Promise<TexConvert> {
11
14
  if (tex2svg) return tex2svg;
12
- const { mathjax } = await import('mathjax-full/js/mathjax.js');
13
- const { TeX } = await import('mathjax-full/js/input/tex.js');
14
- const { SVG } = await import('mathjax-full/js/output/svg.js');
15
- const { liteAdaptor } = await import('mathjax-full/js/adaptors/liteAdaptor.js');
16
- const { RegisterHTMLHandler } = await import('mathjax-full/js/handlers/html.js');
17
- const adaptor = liteAdaptor();
15
+
16
+ const { mathjax } = await import('@mathjax/src/js/mathjax.js');
17
+ const { TeX } = await import('@mathjax/src/js/input/tex.js');
18
+ const { SVG } = await import('@mathjax/src/js/output/svg.js');
19
+ const { liteAdaptor } = await import('@mathjax/src/js/adaptors/liteAdaptor.js');
20
+ const { RegisterHTMLHandler } = await import('@mathjax/src/js/handlers/html.js');
21
+ await import('@mathjax/src/js/util/asyncLoad/esm.js');
22
+ await import('@mathjax/src/js/input/tex/base/BaseConfiguration.js');
23
+ await import('@mathjax/src/js/input/tex/ams/AmsConfiguration.js');
24
+
25
+ const adaptor = liteAdaptor({ fontSize: EM });
18
26
  RegisterHTMLHandler(adaptor);
27
+
19
28
  const html = mathjax.document('', {
20
29
  InputJax: new TeX({ packages: ['base', 'ams'] }),
21
- OutputJax: new SVG({ fontCache: 'none' }),
30
+ OutputJax: new SVG({ fontCache: 'none', exFactor: EX / EM }),
22
31
  });
32
+
23
33
  tex2svg = (tex, display) => {
24
- const node = html.convert(tex ?? '', { display: !!display });
34
+ const node = html.convert(tex ?? '', {
35
+ display: !!display,
36
+ em: EM,
37
+ ex: EX,
38
+ containerWidth: 80 * EM,
39
+ });
25
40
  return adaptor.outerHTML(node);
26
41
  };
27
42
  return tex2svg;