@wordpress/latex-to-mathml 2.1.0 → 2.3.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/build/index.cjs CHANGED
@@ -11,12 +11,14 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
11
11
  var __getProtoOf = Object.getPrototypeOf;
12
12
  var __hasOwnProp = Object.prototype.hasOwnProperty;
13
13
  var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
15
- key = keys[i];
16
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
- get: ((k) => from[k]).bind(null, key),
18
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
- });
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) {
16
+ desc = __getOwnPropDesc(from, key);
17
+ __defProp(to, key, {
18
+ get: desc && desc.get && !desc.configurable ? desc.get : () => from[key],
19
+ enumerable: !desc || desc.enumerable
20
+ });
21
+ }
20
22
  }
21
23
  return to;
22
24
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import temml from 'temml';\n\n/**\n * Options for LaTeX to MathML conversion.\n */\nexport interface LatexToMathMLOptions {\n\t/**\n\t * Whether to render in display mode (block) or inline mode.\n\t * @default true\n\t */\n\tdisplayMode?: boolean;\n}\n\n/**\n * Converts LaTeX math syntax to MathML.\n *\n * @param latex - The LaTeX string to convert.\n * @param options - Conversion options.\n * @param options.displayMode\n * @return The MathML string.\n * @throws Will throw an error if the LaTeX is invalid.\n *\n * @example\n * ```js\n * import latexToMathML from '@wordpress/latex-to-mathml';\n *\n * const mathML = latexToMathML( 'x^2', { displayMode: false } );\n * ```\n */\nexport default function latexToMathML(\n\tlatex: string,\n\t{ displayMode = true }: LatexToMathMLOptions = {}\n): string {\n\tconst mathML = temml.renderToString( latex, {\n\t\tdisplayMode,\n\t\tannotate: true,\n\t\tthrowOnError: true,\n\t} );\n\tconst doc = document.implementation.createHTMLDocument( '' );\n\tdoc.body.innerHTML = mathML;\n\tconst math = doc.body.querySelector( 'math' );\n\tif ( ! math ) {\n\t\treturn '';\n\t}\n\n\t// temml marks the cells of `aligned`, `cases` and tagged equations with\n\t// classes for its own stylesheet. Write the MathML `columnalign`\n\t// attribute on the cell instead, so the alignment is part of the content:\n\t// Firefox and Safari honor it natively, and the polyfill in `style.scss`\n\t// covers Chromium, which implements MathML Core only.\n\tfor ( const cell of math.querySelectorAll(\n\t\t'mtd.tml-right, mtd.tml-left'\n\t) ) {\n\t\tcell.setAttribute(\n\t\t\t'columnalign',\n\t\t\tcell.classList.contains( 'tml-right' ) ? 'right' : 'left'\n\t\t);\n\t}\n\n\t// The remaining classes are hooks for temml's stylesheet, which is not\n\t// used. Drop them so the content is plain MathML and does not depend on\n\t// the class names of a temml version.\n\tfor ( const element of math.querySelectorAll( '[class]' ) ) {\n\t\telement.removeAttribute( 'class' );\n\t}\n\n\treturn math.innerHTML;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,SAAwB,cACvB,OACA,EAAE,cAAc,SAA+B,CAAC,GACvC;CACT,MAAM,SAAS,MAAA,QAAM,eAAgB,OAAO;EAC3C;EACA,UAAU;EACV,cAAc;CACf,CAAE;CACF,MAAM,MAAM,SAAS,eAAe,mBAAoB,EAAG;CAC3D,IAAI,KAAK,YAAY;CACrB,MAAM,OAAO,IAAI,KAAK,cAAe,MAAO;CAC5C,IAAK,CAAE,MACN,OAAO;CAQR,KAAM,MAAM,QAAQ,KAAK,iBACxB,6BACD,GACC,KAAK,aACJ,eACA,KAAK,UAAU,SAAU,WAAY,IAAI,UAAU,MACpD;CAMD,KAAM,MAAM,WAAW,KAAK,iBAAkB,SAAU,GACvD,QAAQ,gBAAiB,OAAQ;CAGlC,OAAO,KAAK;AACb"}
1
+ {"version":3,"file":"index.cjs","names":["temml"],"sources":["../src/index.ts"],"sourcesContent":["import temml from 'temml';\n\n/**\n * Options for LaTeX to MathML conversion.\n */\nexport interface LatexToMathMLOptions {\n\t/**\n\t * Whether to render in display mode (block) or inline mode.\n\t * @default true\n\t */\n\tdisplayMode?: boolean;\n}\n\n/**\n * Converts LaTeX math syntax to MathML.\n *\n * @param latex - The LaTeX string to convert.\n * @param options - Conversion options.\n * @param options.displayMode\n * @return The MathML string.\n * @throws Will throw an error if the LaTeX is invalid.\n *\n * @example\n * ```js\n * import latexToMathML from '@wordpress/latex-to-mathml';\n *\n * const mathML = latexToMathML( 'x^2', { displayMode: false } );\n * ```\n */\nexport default function latexToMathML(\n\tlatex: string,\n\t{ displayMode = true }: LatexToMathMLOptions = {}\n): string {\n\tconst mathML = temml.renderToString( latex, {\n\t\tdisplayMode,\n\t\tannotate: true,\n\t\tthrowOnError: true,\n\t} );\n\tconst doc = document.implementation.createHTMLDocument( '' );\n\tdoc.body.innerHTML = mathML;\n\tconst math = doc.body.querySelector( 'math' );\n\tif ( ! math ) {\n\t\treturn '';\n\t}\n\n\t// temml marks the cells of `aligned`, `cases` and tagged equations with\n\t// classes for its own stylesheet. Write the MathML `columnalign`\n\t// attribute on the cell instead, so the alignment is part of the content:\n\t// Firefox and Safari honor it natively, and the polyfill in `style.scss`\n\t// covers Chromium, which implements MathML Core only.\n\tfor ( const cell of math.querySelectorAll(\n\t\t'mtd.tml-right, mtd.tml-left'\n\t) ) {\n\t\tcell.setAttribute(\n\t\t\t'columnalign',\n\t\t\tcell.classList.contains( 'tml-right' ) ? 'right' : 'left'\n\t\t);\n\t}\n\n\t// The remaining classes are hooks for temml's stylesheet, which is not\n\t// used. Drop them so the content is plain MathML and does not depend on\n\t// the class names of a temml version.\n\tfor ( const element of math.querySelectorAll( '[class]' ) ) {\n\t\telement.removeAttribute( 'class' );\n\t}\n\n\treturn math.innerHTML;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,SAAwB,cACvB,OACA,EAAE,cAAc,SAA+B,CAAC,GACvC;CACT,MAAM,SAASA,MAAAA,QAAM,eAAgB,OAAO;EAC3C;EACA,UAAU;EACV,cAAc;CACf,CAAE;CACF,MAAM,MAAM,SAAS,eAAe,mBAAoB,EAAG;CAC3D,IAAI,KAAK,YAAY;CACrB,MAAM,OAAO,IAAI,KAAK,cAAe,MAAO;CAC5C,IAAK,CAAE,MACN,OAAO;CAQR,KAAM,MAAM,QAAQ,KAAK,iBACxB,6BACD,GACC,KAAK,aACJ,eACA,KAAK,UAAU,SAAU,WAAY,IAAI,UAAU,MACpD;CAMD,KAAM,MAAM,WAAW,KAAK,iBAAkB,SAAU,GACvD,QAAQ,gBAAiB,OAAQ;CAGlC,OAAO,KAAK;AACb"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/latex-to-mathml",
3
- "version": "2.1.0",
3
+ "version": "2.3.0",
4
4
  "description": "Convert LaTeX math syntax to MathML.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -48,10 +48,10 @@
48
48
  "temml": "^0.10.33"
49
49
  },
50
50
  "devDependencies": {
51
- "vitest": "^5.0.5"
51
+ "vitest": "^5.1.1"
52
52
  },
53
53
  "publishConfig": {
54
54
  "access": "public"
55
55
  },
56
- "gitHead": "9b70363b9f93cff0583a1f3153738d383cf5a49e"
56
+ "gitHead": "7f19202f61aeba8f4bdce892a1a0df485ad76e2b"
57
57
  }