@pie-lib/math-rendering 2.3.9 → 2.3.12

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/CHANGELOG.json CHANGED
@@ -653,5 +653,20 @@
653
653
  "committerDate": "2021-08-17 10:59:50 +0300",
654
654
  "isTagged": true,
655
655
  "tag": "@pie-lib/math-rendering@2.3.9"
656
+ },
657
+ {
658
+ "type": "fix",
659
+ "scope": null,
660
+ "subject": "wip",
661
+ "merge": null,
662
+ "header": "fix: wip",
663
+ "body": null,
664
+ "footer": null,
665
+ "notes": [],
666
+ "hash": "fe4316df075edfc2c0565641b58c4ca453057651",
667
+ "gitTags": " (origin/fix/fix-math-module)",
668
+ "committerDate": "2021-09-06 13:29:44 +0100",
669
+ "isTagged": true,
670
+ "tag": "@pie-lib/math-rendering@2.3.10"
656
671
  }
657
672
  ]
package/CHANGELOG.md CHANGED
@@ -3,98 +3,86 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- ## [2.3.9](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-rendering@2.3.8...@pie-lib/math-rendering@2.3.9) (2021-08-30)
6
+ ## [2.3.12](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-rendering@2.3.11...@pie-lib/math-rendering@2.3.12) (2021-11-29)
7
7
 
8
+ **Note:** Version bump only for package @pie-lib/math-rendering
8
9
 
9
- ### Bug Fixes
10
10
 
11
- * **math-rendering:** fix symbols in math markup that trigger undefined control sequence error PD-1267, PD-368, PD-1173 ([a7d9934](https://github.com/pie-framework/pie-lib/commit/a7d9934))
12
11
 
13
12
 
14
13
 
14
+ ## [2.3.11](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-rendering@2.3.10...@pie-lib/math-rendering@2.3.11) (2021-09-08)
15
15
 
16
+ **Note:** Version bump only for package @pie-lib/math-rendering
16
17
 
17
- ## [2.3.8](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-rendering@2.3.6...@pie-lib/math-rendering@2.3.8) (2021-06-25)
18
18
 
19
- **Note:** Version bump only for package @pie-lib/math-rendering
20
19
 
21
20
 
22
21
 
22
+ ## [2.3.10](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-rendering@2.3.9...@pie-lib/math-rendering@2.3.10) (2021-09-08)
23
23
 
24
24
 
25
- ## [2.3.6](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-rendering@2.3.5...@pie-lib/math-rendering@2.3.6) (2021-03-01)
25
+ ### Bug Fixes
26
26
 
27
- **Note:** Version bump only for package @pie-lib/math-rendering
27
+ * wip ([fe4316d](https://github.com/pie-framework/pie-lib/commit/fe4316d))
28
28
 
29
29
 
30
30
 
31
31
 
32
32
 
33
- ## [2.3.5](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-rendering@2.3.4...@pie-lib/math-rendering@2.3.5) (2021-03-01)
33
+ ## [2.3.9](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-rendering@2.3.8...@pie-lib/math-rendering@2.3.9) (2021-08-30)
34
34
 
35
35
 
36
36
  ### Bug Fixes
37
37
 
38
- * **math-rendering:** linebreak rendering fixed for mathquill custom elements - PD-787 ([5216f6a](https://github.com/pie-framework/pie-lib/commit/5216f6a))
38
+ * **math-rendering:** fix symbols in math markup that trigger undefined control sequence error PD-1267, PD-368, PD-1173 ([a7d9934](https://github.com/pie-framework/pie-lib/commit/a7d9934))
39
39
 
40
40
 
41
41
 
42
42
 
43
43
 
44
- ## [2.3.4](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-rendering@2.3.3...@pie-lib/math-rendering@2.3.4) (2021-02-15)
44
+ ## [2.3.8](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-rendering@2.3.6...@pie-lib/math-rendering@2.3.8) (2021-06-25)
45
45
 
46
46
  **Note:** Version bump only for package @pie-lib/math-rendering
47
47
 
48
+ ## [2.3.6](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-rendering@2.3.5...@pie-lib/math-rendering@2.3.6) (2021-03-01)
48
49
 
50
+ **Note:** Version bump only for package @pie-lib/math-rendering
49
51
 
52
+ ## [2.3.5](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-rendering@2.3.4...@pie-lib/math-rendering@2.3.5) (2021-03-01)
50
53
 
54
+ ### Bug Fixes
51
55
 
52
- ## [2.3.3](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-rendering@2.3.1...@pie-lib/math-rendering@2.3.3) (2021-02-15)
53
-
54
- **Note:** Version bump only for package @pie-lib/math-rendering
56
+ - **math-rendering:** linebreak rendering fixed for mathquill custom elements - PD-787 ([5216f6a](https://github.com/pie-framework/pie-lib/commit/5216f6a))
55
57
 
58
+ ## [2.3.4](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-rendering@2.3.3...@pie-lib/math-rendering@2.3.4) (2021-02-15)
56
59
 
60
+ **Note:** Version bump only for package @pie-lib/math-rendering
57
61
 
62
+ ## [2.3.3](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-rendering@2.3.1...@pie-lib/math-rendering@2.3.3) (2021-02-15)
58
63
 
64
+ **Note:** Version bump only for package @pie-lib/math-rendering
59
65
 
60
66
  ## [2.3.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-rendering@2.3.0...@pie-lib/math-rendering@2.3.1) (2021-01-28)
61
67
 
62
-
63
68
  ### Bug Fixes
64
69
 
65
- * add lodash dependency ([de2227f](https://github.com/pie-framework/pie-lib/commit/de2227f))
66
-
67
-
68
-
69
-
70
+ - add lodash dependency ([de2227f](https://github.com/pie-framework/pie-lib/commit/de2227f))
70
71
 
71
72
  # [2.3.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-rendering@2.2.4...@pie-lib/math-rendering@2.3.0) (2021-01-25)
72
73
 
73
-
74
74
  ### Features
75
75
 
76
- * demo changes include for the issue PD-368 ([c493d9f](https://github.com/pie-framework/pie-lib/commit/c493d9f))
77
-
78
-
79
-
80
-
76
+ - demo changes include for the issue PD-368 ([c493d9f](https://github.com/pie-framework/pie-lib/commit/c493d9f))
81
77
 
82
78
  ## [2.2.4](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-rendering@2.2.3...@pie-lib/math-rendering@2.2.4) (2021-01-11)
83
79
 
84
80
  **Note:** Version bump only for package @pie-lib/math-rendering
85
81
 
86
-
87
-
88
-
89
-
90
82
  ## [2.2.3](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-rendering@2.2.2...@pie-lib/math-rendering@2.2.3) (2020-10-26)
91
83
 
92
84
  **Note:** Version bump only for package @pie-lib/math-rendering
93
85
 
94
-
95
-
96
-
97
-
98
86
  ## [2.2.2](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-rendering@2.2.1...@pie-lib/math-rendering@2.2.2) (2020-10-26)
99
87
 
100
88
  **Note:** Version bump only for package @pie-lib/math-rendering
@@ -231,7 +231,8 @@ var renderMath = function renderMath(el, renderOpts) {
231
231
  _mspace.CHTMLmspace.styles = {
232
232
  'mjx-mspace': {
233
233
  display: 'block',
234
- 'text-align': 'center'
234
+ 'text-align': 'center',
235
+ height: '5px'
235
236
  }
236
237
  };
237
238
  var _default = renderMath;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/render-math.js"],"names":["window","log","NEWLINE_BLOCK_REGEX","NEWLINE_LATEX","getGlobal","key","pkg","name","version","split","defaultOpts","opts","fixMathElement","element","property","textContent","unwrapped","replace","fixMathElements","mathElements","document","querySelectorAll","forEach","item","bootstrap","Typeset","useSingleDollar","console","warn","packages","AllPackages","filter","push","macros","parallelogram","overarc","napprox","longdiv","texConfig","inlineMath","processEscapes","mmlConfig","parseError","node","error","adaptor","fontURL","mathjax","htmlConfig","wrapperFactory","CHTMLWrapperFactory","defaultNodes","chtmlNodes","mml","MathML","customMmlFactory","MmlFactory","mmlNodes","html","compileError","mj","math","err","typesetError","doc","InputJax","TeX","OutputJax","CHTML","setMmlFactory","elements","findMath","length","compile","getMetrics","typeset","updateDocument","clear","renderMath","el","renderOpts","instance","Element","arr","Array","from","CHTMLmspace","styles","display"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;AAVA,IAAI,OAAOA,MAAP,KAAkB,WAAtB,EAAmC;AACjC,iCAAoB,qCAApB;AACD;;AAUD,IAAMC,GAAG,GAAG,uBAAM,wBAAN,CAAZ;AAEA,IAAMC,mBAAmB,GAAG,yBAA5B;AACA,IAAMC,aAAa,GAAG,YAAtB;;AAEA,IAAMC,SAAS,GAAG,SAAZA,SAAY,GAAM;AACtB,MAAMC,GAAG,aAAMC,oBAAIC,IAAV,cAAkBD,oBAAIE,OAAJ,CAAYC,KAAZ,CAAkB,GAAlB,EAAuB,CAAvB,CAAlB,CAAT;;AAEA,MAAI,OAAOT,MAAP,KAAkB,WAAtB,EAAmC;AACjC,QAAI,CAACA,MAAM,CAACK,GAAD,CAAX,EAAkB;AAChBL,MAAAA,MAAM,CAACK,GAAD,CAAN,GAAc,EAAd;AACD;;AACD,WAAOL,MAAM,CAACK,GAAD,CAAb;AACD,GALD,MAKO;AACL,WAAO,EAAP;AACD;AACF,CAXD;AAaA;;;;;;;;;AAOA,IAAMK,WAAW,GAAG,SAAdA,WAAc;AAAA,SAAMN,SAAS,GAAGO,IAAZ,IAAoB,EAA1B;AAAA,CAApB;;AAEO,IAAMC,cAAc,GAAG,SAAjBA,cAAiB,CAAAC,OAAO,EAAI;AACvC,MAAIC,QAAQ,GAAG,WAAf;;AAEA,MAAID,OAAO,CAACE,WAAZ,EAAyB;AACvBD,IAAAA,QAAQ,GAAG,aAAX;AACD;;AAED,MAAID,OAAO,CAACC,QAAD,CAAX,EAAuB;AACrBD,IAAAA,OAAO,CAACC,QAAD,CAAP,GAAoB,6BAAS,+BAAWD,OAAO,CAACC,QAAD,CAAlB,EAA8BE,SAAvC,CAApB,CADqB,CA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ACC,IAAN,CAAWN,EAAX,CAAZ;;AACA,2BAAA3E,SAAS,GAAG6E,QAAZ,EAAqBxD,OAArB,+CAAgC0D,GAAhC;AACD;AACF,CAnBD;AAqBA;;;;;;;;;;;AASAG,oBAAYC,MAAZ,GAAqB;AACnB,gBAAc;AACZC,IAAAA,OAAO,EAAE,OADG;AAEZ,kBAAc;AAFF;AADK,CAArB;eAOeV,U","sourcesContent":["import { mathjax } from 'mathjax-full/js/mathjax';\nimport { MathML } from 'mathjax-full/js/input/mathml';\nimport { TeX } from 'mathjax-full/js/input/tex';\n\nimport { CHTML } from 'mathjax-full/js/output/chtml';\nimport { RegisterHTMLHandler } from 'mathjax-full/js/handlers/html';\nimport { browserAdaptor } from 'mathjax-full/js/adaptors/browserAdaptor';\nimport { AllPackages } from 'mathjax-full/js/input/tex/AllPackages';\n\nif (typeof window !== 'undefined') {\n RegisterHTMLHandler(browserAdaptor());\n}\n\nimport pkg from '../package.json';\nimport { mmlNodes, chtmlNodes } from './mstack';\nimport debug from 'debug';\nimport { wrapMath, unWrapMath } from './normalization';\nimport { MmlFactory } from 'mathjax-full/js/core/MmlTree/MmlFactory';\nimport { CHTMLWrapperFactory } from 'mathjax-full/js/output/chtml/WrapperFactory';\nimport { CHTMLmspace } from 'mathjax-full/js/output/chtml/Wrappers/mspace';\n\nconst log = debug('pie-lib:math-rendering');\n\nconst NEWLINE_BLOCK_REGEX = /\\\\embed\\{newLine\\}\\[\\]/g;\nconst NEWLINE_LATEX = '\\\\newline ';\n\nconst getGlobal = () => {\n const key = `${pkg.name}@${pkg.version.split('.')[0]}`;\n\n if (typeof window !== 'undefined') {\n if (!window[key]) {\n window[key] = {};\n }\n return window[key];\n } else {\n return {};\n }\n};\n\n/** Add temporary support for a global singleDollar override\n * <code>\n * // This will enable single dollar rendering\n * window.pie = window.pie || {};\n * window.pie.mathRendering = {useSingleDollar: true };\n * </code>\n */\nconst defaultOpts = () => getGlobal().opts || {};\n\nexport const fixMathElement = element => {\n let property = 'innerText';\n\n if (element.textContent) {\n property = 'textContent';\n }\n\n if (element[property]) {\n element[property] = wrapMath(unWrapMath(element[property]).unwrapped);\n // because mathquill doesn't understand line breaks, sometimes we end up with custom elements on prompts/rationale/etc.\n // we need to replace the custom embedded elements with valid latex that Mathjax can understand\n element[property] = element[property].replace(NEWLINE_BLOCK_REGEX, NEWLINE_LATEX);\n }\n};\n\nexport const fixMathElements = () => {\n const mathElements = document.querySelectorAll('[data-latex]');\n\n mathElements.forEach(item => fixMathElement(item));\n};\n\nconst bootstrap = opts => {\n if (typeof window === 'undefined') {\n return { Typeset: () => ({}) };\n }\n\n opts = opts || defaultOpts();\n\n if (opts.useSingleDollar) {\n // eslint-disable-next-line\n console.warn('[math-rendering] using $ is not advisable, please use $$..$$ or \\\\(...\\\\)');\n }\n\n const packages = AllPackages.filter(name => name !== 'bussproofs'); // Bussproofs needs an output jax\n\n // The autoload extension predefines all the macros from the extensions that haven't been loaded already\n // so that they automatically load the needed extension when they are first used\n packages.push('autoload');\n\n const macros = {\n parallelogram: '\\\\lower.2em{\\\\Huge\\\\unicode{x25B1}}',\n overarc: '\\\\overparen',\n napprox: '\\\\not\\\\approx',\n longdiv: '\\\\enclose{longdiv}'\n };\n\n const texConfig = opts.useSingleDollar\n ? {\n packages,\n macros,\n inlineMath: [['$', '$'], ['\\\\(', '\\\\)']],\n processEscapes: true\n }\n : {\n packages,\n macros\n };\n\n const mmlConfig = {\n parseError: function(node) {\n // function to process parsing errors\n console.log('error:', node);\n this.error(this.adaptor.textContent(node).replace(/\\n.*/g, ''));\n }\n };\n\n const fontURL = `https://unpkg.com/mathjax-full@${mathjax.version}/ts/output/chtml/fonts/tex-woff-v2`;\n const htmlConfig = {\n fontURL,\n\n wrapperFactory: new CHTMLWrapperFactory({\n ...CHTMLWrapperFactory.defaultNodes,\n ...chtmlNodes\n })\n };\n\n const mml = new MathML(mmlConfig);\n\n const customMmlFactory = new MmlFactory({\n ...MmlFactory.defaultNodes,\n ...mmlNodes\n });\n\n const html = mathjax.document(document, {\n compileError: (mj, math, err) => {\n console.log('bad math?:', math);\n console.error(err);\n },\n typesetError: function(doc, math, err) {\n console.log('typeset error');\n console.error(err);\n doc.typesetError(math, err);\n },\n\n InputJax: [new TeX(texConfig), mml],\n OutputJax: new CHTML(htmlConfig)\n });\n\n // Note: we must set this *after* mathjax.document (no idea why)\n mml.setMmlFactory(customMmlFactory);\n\n return {\n version: mathjax.version,\n html: html,\n\n Typeset: function(...elements) {\n this.html\n .findMath(elements.length ? { elements } : {})\n .compile()\n .getMetrics()\n .typeset()\n .updateDocument()\n .clear();\n }\n };\n};\n\nconst renderMath = (el, renderOpts) => {\n //TODO: remove this - has nothing to do with math-rendering (it's from editable-html)\n fixMathElements();\n\n if (!getGlobal().instance) {\n getGlobal().instance = bootstrap(renderOpts);\n }\n\n if (!el) {\n log('el is undefined');\n return;\n }\n\n if (el instanceof Element) {\n getGlobal().instance.Typeset(el);\n } else if (el.length) {\n const arr = Array.from(el);\n getGlobal().instance.Typeset(...arr);\n }\n};\n\n/**\n * This style is added to overried default styling of mjx-mspace Mathjax tag\n * In mathjax src code \\newline latex gets parsed to <mjx-mspace></mjx-mspace>,\n * but has the default style\n * 'mjx-mspace': {\n \"display\": 'in-line',\n \"text-align\": 'left'\n } which prevents it from showing as a newline value\n */\nCHTMLmspace.styles = {\n 'mjx-mspace': {\n display: 'block',\n 'text-align': 'center'\n }\n};\n\nexport default renderMath;\n"],"file":"render-math.js"}
1
+ {"version":3,"sources":["../src/render-math.js"],"names":["window","log","NEWLINE_BLOCK_REGEX","NEWLINE_LATEX","getGlobal","key","pkg","name","version","split","defaultOpts","opts","fixMathElement","element","property","textContent","unwrapped","replace","fixMathElements","mathElements","document","querySelectorAll","forEach","item","bootstrap","Typeset","useSingleDollar","console","warn","packages","AllPackages","filter","push","macros","parallelogram","overarc","napprox","longdiv","texConfig","inlineMath","processEscapes","mmlConfig","parseError","node","error","adaptor","fontURL","mathjax","htmlConfig","wrapperFactory","CHTMLWrapperFactory","defaultNodes","chtmlNodes","mml","MathML","customMmlFactory","MmlFactory","mmlNodes","html","compileError","mj","math","err","typesetError","doc","InputJax","TeX","OutputJax","CHTML","setMmlFactory","elements","findMath","length","compile","getMetrics","typeset","updateDocument","clear","renderMath","el","renderOpts","instance","Element","arr","Array","from","CHTMLmspace","styles","display","height"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;AAVA,IAAI,OAAOA,MAAP,KAAkB,WAAtB,EAAmC;AACjC,iCAAoB,qCAApB;AACD;;AAUD,IAAMC,GAAG,GAAG,uBAAM,wBAAN,CAAZ;AAEA,IAAMC,mBAAmB,GAAG,yBAA5B;AACA,IAAMC,aAAa,GAAG,YAAtB;;AAEA,IAAMC,SAAS,GAAG,SAAZA,SAAY,GAAM;AACtB,MAAMC,GAAG,aAAMC,oBAAIC,IAAV,cAAkBD,oBAAIE,OAAJ,CAAYC,KAAZ,CAAkB,GAAlB,EAAuB,CAAvB,CAAlB,CAAT;;AAEA,MAAI,OAAOT,MAAP,KAAkB,WAAtB,EAAmC;AACjC,QAAI,CAACA,MAAM,CAACK,GAAD,CAAX,EAAkB;AAChBL,MAAAA,MAAM,CAACK,GAAD,CAAN,GAAc,EAAd;AACD;;AACD,WAAOL,MAAM,CAACK,GAAD,CAAb;AACD,GALD,MAKO;AACL,WAAO,EAAP;AACD;AACF,CAXD;AAaA;;;;;;;;;AAOA,IAAMK,WAAW,GAAG,SAAdA,WAAc;AAAA,SAAMN,SAAS,GAAGO,IAAZ,IAAoB,EAA1B;AAAA,CAApB;;AAEO,IAAMC,cAAc,GAAG,SAAjBA,cAAiB,CAAAC,OAAO,EAAI;AACvC,MAAIC,QAAQ,GAAG,WAAf;;AAEA,MAAID,OAAO,CAACE,WAAZ,EAAyB;AACvBD,IAAAA,QAAQ,GAAG,aAAX;AACD;;AAED,MAAID,OAAO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AAS,GAAG6E,QAAZ,CAAqBxD,OAArB,CAA6BsD,EAA7B;AACD,GAFD,MAEO,IAAIA,EAAE,CAACP,MAAP,EAAe;AAAA;;AACpB,QAAMW,GAAG,GAAGC,KAAK,CAACC,IAAN,CAAWN,EAAX,CAAZ;;AACA,2BAAA3E,SAAS,GAAG6E,QAAZ,EAAqBxD,OAArB,+CAAgC0D,GAAhC;AACD;AACF,CAnBD;AAqBA;;;;;;;;;;;AASAG,oBAAYC,MAAZ,GAAqB;AACnB,gBAAc;AACZC,IAAAA,OAAO,EAAE,OADG;AAEZ,kBAAc,QAFF;AAGZC,IAAAA,MAAM,EAAE;AAHI;AADK,CAArB;eAQeX,U","sourcesContent":["import { mathjax } from 'mathjax-full/js/mathjax';\nimport { MathML } from 'mathjax-full/js/input/mathml';\nimport { TeX } from 'mathjax-full/js/input/tex';\n\nimport { CHTML } from 'mathjax-full/js/output/chtml';\nimport { RegisterHTMLHandler } from 'mathjax-full/js/handlers/html';\nimport { browserAdaptor } from 'mathjax-full/js/adaptors/browserAdaptor';\nimport { AllPackages } from 'mathjax-full/js/input/tex/AllPackages';\n\nif (typeof window !== 'undefined') {\n RegisterHTMLHandler(browserAdaptor());\n}\n\nimport pkg from '../package.json';\nimport { mmlNodes, chtmlNodes } from './mstack';\nimport debug from 'debug';\nimport { wrapMath, unWrapMath } from './normalization';\nimport { MmlFactory } from 'mathjax-full/js/core/MmlTree/MmlFactory';\nimport { CHTMLWrapperFactory } from 'mathjax-full/js/output/chtml/WrapperFactory';\nimport { CHTMLmspace } from 'mathjax-full/js/output/chtml/Wrappers/mspace';\n\nconst log = debug('pie-lib:math-rendering');\n\nconst NEWLINE_BLOCK_REGEX = /\\\\embed\\{newLine\\}\\[\\]/g;\nconst NEWLINE_LATEX = '\\\\newline ';\n\nconst getGlobal = () => {\n const key = `${pkg.name}@${pkg.version.split('.')[0]}`;\n\n if (typeof window !== 'undefined') {\n if (!window[key]) {\n window[key] = {};\n }\n return window[key];\n } else {\n return {};\n }\n};\n\n/** Add temporary support for a global singleDollar override\n * <code>\n * // This will enable single dollar rendering\n * window.pie = window.pie || {};\n * window.pie.mathRendering = {useSingleDollar: true };\n * </code>\n */\nconst defaultOpts = () => getGlobal().opts || {};\n\nexport const fixMathElement = element => {\n let property = 'innerText';\n\n if (element.textContent) {\n property = 'textContent';\n }\n\n if (element[property]) {\n element[property] = wrapMath(unWrapMath(element[property]).unwrapped);\n // because mathquill doesn't understand line breaks, sometimes we end up with custom elements on prompts/rationale/etc.\n // we need to replace the custom embedded elements with valid latex that Mathjax can understand\n element[property] = element[property].replace(NEWLINE_BLOCK_REGEX, NEWLINE_LATEX);\n }\n};\n\nexport const fixMathElements = () => {\n const mathElements = document.querySelectorAll('[data-latex]');\n\n mathElements.forEach(item => fixMathElement(item));\n};\n\nconst bootstrap = opts => {\n if (typeof window === 'undefined') {\n return { Typeset: () => ({}) };\n }\n\n opts = opts || defaultOpts();\n\n if (opts.useSingleDollar) {\n // eslint-disable-next-line\n console.warn('[math-rendering] using $ is not advisable, please use $$..$$ or \\\\(...\\\\)');\n }\n\n const packages = AllPackages.filter(name => name !== 'bussproofs'); // Bussproofs needs an output jax\n\n // The autoload extension predefines all the macros from the extensions that haven't been loaded already\n // so that they automatically load the needed extension when they are first used\n packages.push('autoload');\n\n const macros = {\n parallelogram: '\\\\lower.2em{\\\\Huge\\\\unicode{x25B1}}',\n overarc: '\\\\overparen',\n napprox: '\\\\not\\\\approx',\n longdiv: '\\\\enclose{longdiv}'\n };\n\n const texConfig = opts.useSingleDollar\n ? {\n packages,\n macros,\n inlineMath: [['$', '$'], ['\\\\(', '\\\\)']],\n processEscapes: true\n }\n : {\n packages,\n macros\n };\n\n const mmlConfig = {\n parseError: function(node) {\n // function to process parsing errors\n console.log('error:', node);\n this.error(this.adaptor.textContent(node).replace(/\\n.*/g, ''));\n }\n };\n\n const fontURL = `https://unpkg.com/mathjax-full@${mathjax.version}/ts/output/chtml/fonts/tex-woff-v2`;\n const htmlConfig = {\n fontURL,\n\n wrapperFactory: new CHTMLWrapperFactory({\n ...CHTMLWrapperFactory.defaultNodes,\n ...chtmlNodes\n })\n };\n\n const mml = new MathML(mmlConfig);\n\n const customMmlFactory = new MmlFactory({\n ...MmlFactory.defaultNodes,\n ...mmlNodes\n });\n\n const html = mathjax.document(document, {\n compileError: (mj, math, err) => {\n console.log('bad math?:', math);\n console.error(err);\n },\n typesetError: function(doc, math, err) {\n console.log('typeset error');\n console.error(err);\n doc.typesetError(math, err);\n },\n\n InputJax: [new TeX(texConfig), mml],\n OutputJax: new CHTML(htmlConfig)\n });\n\n // Note: we must set this *after* mathjax.document (no idea why)\n mml.setMmlFactory(customMmlFactory);\n\n return {\n version: mathjax.version,\n html: html,\n\n Typeset: function(...elements) {\n this.html\n .findMath(elements.length ? { elements } : {})\n .compile()\n .getMetrics()\n .typeset()\n .updateDocument()\n .clear();\n }\n };\n};\n\nconst renderMath = (el, renderOpts) => {\n //TODO: remove this - has nothing to do with math-rendering (it's from editable-html)\n fixMathElements();\n\n if (!getGlobal().instance) {\n getGlobal().instance = bootstrap(renderOpts);\n }\n\n if (!el) {\n log('el is undefined');\n return;\n }\n\n if (el instanceof Element) {\n getGlobal().instance.Typeset(el);\n } else if (el.length) {\n const arr = Array.from(el);\n getGlobal().instance.Typeset(...arr);\n }\n};\n\n/**\n * This style is added to overried default styling of mjx-mspace Mathjax tag\n * In mathjax src code \\newline latex gets parsed to <mjx-mspace></mjx-mspace>,\n * but has the default style\n * 'mjx-mspace': {\n \"display\": 'in-line',\n \"text-align\": 'left'\n } which prevents it from showing as a newline value\n */\nCHTMLmspace.styles = {\n 'mjx-mspace': {\n display: 'block',\n 'text-align': 'center',\n height: '5px'\n }\n};\n\nexport default renderMath;\n"],"file":"render-math.js"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-lib/math-rendering",
3
- "version": "2.3.9",
3
+ "version": "2.3.12",
4
4
  "description": "math rendering utilities",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -12,8 +12,8 @@
12
12
  "dependencies": {
13
13
  "debug": "^4.1.1",
14
14
  "lodash": "^4.17.11",
15
- "mathjax-full": "^3.1.2"
15
+ "mathjax-full": "^3.2.0"
16
16
  },
17
- "gitHead": "de37d3ba44d3e7934e2f804381fe50d2da16a29a",
17
+ "gitHead": "3575de076034eb451b0a66b2f3fd3d29802983ec",
18
18
  "scripts": {}
19
19
  }
@@ -196,7 +196,8 @@ const renderMath = (el, renderOpts) => {
196
196
  CHTMLmspace.styles = {
197
197
  'mjx-mspace': {
198
198
  display: 'block',
199
- 'text-align': 'center'
199
+ 'text-align': 'center',
200
+ height: '5px'
200
201
  }
201
202
  };
202
203