@ai-gui/plugin-katex 0.8.0 → 0.9.0

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.
package/dist/index.cjs CHANGED
@@ -139,11 +139,8 @@ function mathBlock(state, start, end, silent) {
139
139
  }
140
140
  /** KaTeX stylesheet import hint — consumers must load KaTeX's CSS for correct layout. */
141
141
  const katexCss = "@import \"katex/dist/katex.min.css\";";
142
- /**
143
- * KaTeX plugin: renders inline `$...$` and block `$$...$$` math to HTML during
144
- * markdown parsing, flowing through the core Renderer's sanitized `html` pipeline.
145
- */
146
- function katex$1() {
142
+ function katex$1(options = {}) {
143
+ if (options.chemistry) import("katex/contrib/mhchem").catch(() => {});
147
144
  return {
148
145
  name: "katex",
149
146
  css: katexCss,
package/dist/index.d.cts CHANGED
@@ -8,7 +8,15 @@ declare const katexCss = "@import \"katex/dist/katex.min.css\";";
8
8
  * KaTeX plugin: renders inline `$...$` and block `$$...$$` math to HTML during
9
9
  * markdown parsing, flowing through the core Renderer's sanitized `html` pipeline.
10
10
  */
11
- declare function katex(): AIGuiPlugin;
12
-
13
- //#endregion
14
- export { katex, katexCss };
11
+ interface KatexOptions {
12
+ /**
13
+ * Load KaTeX's mhchem extension, which is what renders `\ce{}` and `\pu{}`.
14
+ *
15
+ * Chemistry teaching runs on that notation — "\ce{2H2 + O2 -> 2H2O}" is how a reaction is
16
+ * written — and without the extension KaTeX renders it as an error. It is off by default because
17
+ * mhchem is a chunk of grammar that a maths or physics lesson never touches.
18
+ */
19
+ chemistry?: boolean;
20
+ }
21
+ declare function katex(options?: KatexOptions): AIGuiPlugin; //#endregion
22
+ export { KatexOptions, katex, katexCss };
package/dist/index.d.ts CHANGED
@@ -8,7 +8,15 @@ declare const katexCss = "@import \"katex/dist/katex.min.css\";";
8
8
  * KaTeX plugin: renders inline `$...$` and block `$$...$$` math to HTML during
9
9
  * markdown parsing, flowing through the core Renderer's sanitized `html` pipeline.
10
10
  */
11
- declare function katex(): AIGuiPlugin;
12
-
13
- //#endregion
14
- export { katex, katexCss };
11
+ interface KatexOptions {
12
+ /**
13
+ * Load KaTeX's mhchem extension, which is what renders `\ce{}` and `\pu{}`.
14
+ *
15
+ * Chemistry teaching runs on that notation — "\ce{2H2 + O2 -> 2H2O}" is how a reaction is
16
+ * written — and without the extension KaTeX renders it as an error. It is off by default because
17
+ * mhchem is a chunk of grammar that a maths or physics lesson never touches.
18
+ */
19
+ chemistry?: boolean;
20
+ }
21
+ declare function katex(options?: KatexOptions): AIGuiPlugin; //#endregion
22
+ export { KatexOptions, katex, katexCss };
package/dist/index.js CHANGED
@@ -115,11 +115,8 @@ function mathBlock(state, start, end, silent) {
115
115
  }
116
116
  /** KaTeX stylesheet import hint — consumers must load KaTeX's CSS for correct layout. */
117
117
  const katexCss = "@import \"katex/dist/katex.min.css\";";
118
- /**
119
- * KaTeX plugin: renders inline `$...$` and block `$$...$$` math to HTML during
120
- * markdown parsing, flowing through the core Renderer's sanitized `html` pipeline.
121
- */
122
- function katex() {
118
+ function katex(options = {}) {
119
+ if (options.chemistry) import("katex/contrib/mhchem").catch(() => {});
123
120
  return {
124
121
  name: "katex",
125
122
  css: katexCss,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-gui/plugin-katex",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "KaTeX math rendering plugin for AIGUI.",
5
5
  "keywords": [
6
6
  "llm",
@@ -52,7 +52,7 @@
52
52
  },
53
53
  "dependencies": {
54
54
  "katex": "^0.16.11",
55
- "@ai-gui/core": "0.8.0"
55
+ "@ai-gui/core": "0.9.0"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@types/katex": "^0.16.7",