@pie-lib/math-rendering-accessible 3.22.2-next.11 → 3.22.2-next.171
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.md +13 -59
- package/esm/index.js +57 -88
- package/esm/index.js.map +1 -1
- package/lib/index.js +0 -4
- package/lib/index.js.map +1 -1
- package/lib/mathjax-script.js.map +1 -1
- package/lib/mml-to-latex.js +1 -5
- package/lib/mml-to-latex.js.map +1 -1
- package/lib/mstack/chtml.js +21 -87
- package/lib/mstack/chtml.js.map +1 -1
- package/lib/mstack/index.js +2 -7
- package/lib/mstack/index.js.map +1 -1
- package/lib/mstack/mml.js +19 -60
- package/lib/mstack/mml.js.map +1 -1
- package/lib/normalization.js +7 -34
- package/lib/normalization.js.map +1 -1
- package/lib/render-math.js +60 -100
- package/lib/render-math.js.map +1 -1
- package/package.json +4 -4
- package/src/__tests__/render-math.test.js +3 -3
- package/src/mstack/__tests__/chtml.test.js +5 -1
- package/src/render-math.js +16 -5
- package/src/mstack/__tests__/__snapshots__/chtml.test.js.snap +0 -9
package/lib/render-math.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/render-math.js"],"names":["visitor","SerializedMmlVisitor","toMMl","node","visitTree","NEWLINE_BLOCK_REGEX","NEWLINE_LATEX","mathRenderingKEY","mathRenderingAccessibleKEY","MathJaxVersion","getGlobal","window","fixMathElement","element","dataset","mathHandled","property","textContent","unwrapped","replace","fixMathElements","el","document","mathElements","querySelectorAll","forEach","item","adjustMathMLStyle","nodes","setAttribute","createPlaceholder","previousSibling","classList","contains","originalDisplay","style","display","placeholder","createElement","cssText","add","parentNode","insertBefore","removePlaceholdersAndRestoreDisplay","targetElement","nextElementSibling","undefined","remove","removeExcessMjxContainers","content","elements","mjxContainers","length","i","removeChild","renderContentsWithMathJax","Array","elNode","renderContentWithMathJax","executeOn","body","HTMLElement","mathJaxInstance","instance","texReset","typesetClear","typesetPromise","then","updatedDocument","startup","list","math","next","data","mathMl","root","parsedMathMl","replaceAll","typesetRoot","e","console","error","toString","clear","convertMathJax2ToMathJax3","CommandMap","MathJax","_","input","tex","SymbolMap","requireMap","config","RequireLoad","require","RequireConfiguration","RequireMethods","Require","parser","name","required","GetArgument","match","TexError","hasOwnProperty","Callback","args","isArray","Object","Function","bind","apply","slice","concat","Error","Hub","Queue","m","arguments","fn","promise","Typeset","callback","Register","MessageHook","log","StartupHook","LoadHook","Config","initializeMathJax","mathjaxLoadedP","PreviousMathJaxIsUsed","version","texConfig","macros","parallelogram","overarc","napprox","longdiv","displayMath","autoload","color","colorv2","Promise","resolve","AMSmath","AMSsymbols","AMScd","HTML","noErrors","noUndefined","typeset","ready","mathjax","STATE","core","MathItem","Menu","ui","menu","rerender","prototype","start","TYPESET","handleRetriesFor","call","defaultReady","globalObj","mathjaxLoadedComplete","Date","loader","load","preLoad","failed","message","chtml","fontURL","displayAlign","customKey","options","enableEnrichment","sre","speech","menuOptions","settings","assistiveMml","collapsible","explorer","script","type","src","async","head","appendChild","setTimeout","renderMath","renderOpts","usedForMmlOutput","div","innerHTML"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AACA;;AAEA,IAAMA,OAAO,GAAG,IAAIC,0CAAJ,EAAhB;;AACA,IAAMC,KAAK,GAAG,SAARA,KAAQ,CAACC,IAAD;AAAA,SAAUH,OAAO,CAACI,SAAR,CAAkBD,IAAlB,CAAV;AAAA,CAAd;;AAEA,IAAME,mBAAmB,GAAG,yBAA5B;AACA,IAAMC,aAAa,GAAG,YAAtB;AAEA,IAAMC,gBAAgB,GAAG,2BAAzB;AACA,IAAMC,0BAA0B,GAAG,sCAAnC;AAEO,IAAMC,cAAc,GAAG,OAAvB;;;AAEA,IAAMC,SAAS,GAAG,SAAZA,SAAY,GAAM;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAI,OAAOC,MAAP,KAAkB,WAAtB,EAAmC;AACjC,QAAI,CAACA,MAAM,CAAC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AAGF,eAAe,CAACG,IAAhB,CAAqBD,IAAlC;AACA,YAAM5C,IAAI,GAAG4C,IAAI,CAACE,IAAlB;AACA,YAAME,MAAM,GAAGxE,KAAK,CAACwB,IAAI,CAAC+C,IAAL,CAAUE,IAAX,CAApB;AAEA,YAAMC,YAAY,GAAGF,MAAM,CAACG,UAAP,CAAkB,IAAlB,EAAwB,EAAxB,CAArB;AAEA,eAAOD,YAAP;AACD,OAZD,CAYE,OAAOK,KAAP,EAAc;AACdD,QAAAA,OAAO,CAACC,KAAR,CAAc,uBAAd,EAAuCA,KAAK,CAAC6F,OAA7C;AACD;;AAED,aAAOzJ,EAAP;AACD;;AAED,WAAOA,EAAP;AACD;AACF,CAnDD,C,CAqDA;;;AACA,CAAC,YAAW;AACV4G,EAAAA,iBAAiB,CAACvE,wBAAD,CAAjB;AAEA/C,EAAAA,MAAM,CAACJ,gBAAD,CAAN,GAA2B;AACzBwD,IAAAA,QAAQ,EAAE;AACR0D,MAAAA,OAAO,EAAE0E;AADD;AADe,GAA3B;AAKD,CARD;;eAUeA,U","sourcesContent":["import { wrapMath, unWrapMath } from './normalization';\nimport { SerializedMmlVisitor } from 'mathjax-full/js/core/MmlTree/SerializedMmlVisitor';\nimport TexError from 'mathjax-full/js/input/tex/TexError';\n\nconst visitor = new SerializedMmlVisitor();\nconst toMMl = (node) => visitor.visitTree(node);\n\nconst NEWLINE_BLOCK_REGEX = /\\\\embed\\{newLine\\}\\[\\]/g;\nconst NEWLINE_LATEX = '\\\\newline ';\n\nconst mathRenderingKEY = '@pie-lib/math-rendering@2';\nconst mathRenderingAccessibleKEY = '@pie-lib/math-rendering-accessible@1';\n\nexport const MathJaxVersion = '3.2.2';\n\nexport const getGlobal = () => {\n // TODO does it make sense to use version?\n // const key = `${pkg.name}@${pkg.version.split('.')[0]}`;\n // It looks like Ed made this change when he switched from mathjax3 to mathjax-full\n // I think it was supposed to make sure version 1 (using mathjax3) is not used\n // in combination with version 2 (using mathjax-full)\n // TODO higher level wrappers use this instance of math-rendering, and if 2 different instances are used, math rendering is not working\n // so I will hardcode this for now until a better solution is found\n if (typeof window !== 'undefined') {\n if (!window[mathRenderingAccessibleKEY]) {\n window[mathRenderingAccessibleKEY] = {};\n }\n return window[mathRenderingAccessibleKEY];\n } else {\n return {};\n }\n};\n\nexport const fixMathElement = (element) => {\n if (element.dataset.mathHandled) {\n return;\n }\n\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 element.dataset.mathHandled = true;\n }\n};\n\nexport const fixMathElements = (el = document) => {\n const mathElements = el.querySelectorAll('[data-latex]');\n\n mathElements.forEach((item) => fixMathElement(item));\n};\n\nconst adjustMathMLStyle = (el = document) => {\n const nodes = el.querySelectorAll('math');\n nodes.forEach((node) => node.setAttribute('displaystyle', 'true'));\n};\n\nconst createPlaceholder = (element) => {\n if (!element.previousSibling || !element.previousSibling.classList?.contains('math-placeholder')) {\n // Store the original display style before setting it to 'none'\n element.dataset.originalDisplay = element.style.display || '';\n element.style.display = 'none';\n\n const placeholder = document.createElement('span');\n placeholder.style.cssText =\n 'height: 10px; width: 50px; display: inline-block; vertical-align: middle; justify-content: center; background: #fafafa; border-radius: 4px;';\n placeholder.classList.add('math-placeholder');\n element.parentNode?.insertBefore(placeholder, element);\n }\n};\n\nconst removePlaceholdersAndRestoreDisplay = () => {\n document.querySelectorAll('.math-placeholder').forEach((placeholder) => {\n const targetElement = placeholder.nextElementSibling;\n\n if (targetElement && targetElement.dataset?.originalDisplay !== undefined) {\n targetElement.style.display = targetElement.dataset.originalDisplay;\n delete targetElement.dataset.originalDisplay;\n }\n\n placeholder.remove();\n });\n};\nconst removeExcessMjxContainers = (content) => {\n const elements = content.querySelectorAll('[data-latex][data-math-handled=\"true\"]');\n\n elements.forEach((element) => {\n const mjxContainers = element.querySelectorAll('mjx-container');\n\n // Check if there are more than one mjx-container children.\n if (mjxContainers.length > 1) {\n for (let i = 1; i < mjxContainers.length; i++) {\n mjxContainers[i].parentNode.removeChild(mjxContainers[i]);\n }\n }\n });\n};\n\nconst renderContentsWithMathJax = (el) => {\n // el sometimes is an array\n // renderMath is used like that in pie-print-support and pie-element-extensions\n // there seems to be no reason for that, however, it's better to handle the case here\n if (el instanceof Array) {\n el.forEach((elNode) => renderContentWithMathJax(elNode));\n } else {\n renderContentWithMathJax(el);\n }\n};\n\nconst renderContentWithMathJax = (executeOn) => {\n executeOn = executeOn || document.body;\n\n // this happens for charting - mark-label; we receive a ref which is not yet ready ( el = { current: null })\n // we have to fix this in charting\n if (!(executeOn instanceof HTMLElement)) return;\n\n fixMathElements(executeOn);\n adjustMathMLStyle(executeOn);\n\n const mathJaxInstance = getGlobal().instance;\n\n if (mathJaxInstance) {\n // Reset and clear typesetting before processing the new content\n // Reset the tex labels (and automatic equation number).\n\n mathJaxInstance.texReset();\n\n // Reset the typesetting system (font caches, etc.)\n mathJaxInstance.typesetClear();\n\n // Use typesetPromise for asynchronous typesetting\n // Using MathJax.typesetPromise() for asynchronous typesetting to handle situations where additional code needs to be loaded (e.g., for certain TeX commands or characters).\n // This ensures typesetting waits for any needed resources to load and complete processing, unlike the synchronous MathJax.typeset() which can't handle such dynamic loading.\n mathJaxInstance\n .typesetPromise([executeOn])\n .then(() => {\n try {\n removePlaceholdersAndRestoreDisplay();\n removeExcessMjxContainers(executeOn);\n\n const updatedDocument = mathJaxInstance.startup.document;\n const list = updatedDocument.math.list;\n\n for (let item = list.next; typeof item.data !== 'symbol'; item = item.next) {\n const mathMl = toMMl(item.data.root);\n const parsedMathMl = mathMl.replaceAll('\\n', '');\n\n item.data.typesetRoot.setAttribute('data-mathml', parsedMathMl);\n item.data.typesetRoot.setAttribute('tabindex', '-1');\n }\n\n // If the original input was a string, return the parsed MathML\n } catch (e) {\n console.error('Error post-processing MathJax typesetting:', e.toString());\n }\n\n // Clearing the document if needed\n mathJaxInstance.startup.document.clear();\n })\n .catch((error) => {\n // If there was an internal error, put the message into the output instead\n\n console.error('Error in typesetting with MathJax:', error);\n });\n }\n};\n\nconst convertMathJax2ToMathJax3 = () => {\n // Make MathJax v2 compatible with v3\n // https://docs.mathjax.org/en/v3.2-latest/upgrading/v2.html#version-2-compatibility-example\n // Replace the require command map with a new one that checks for\n // renamed extensions and converts them to the new names.\n const CommandMap = MathJax._.input.tex.SymbolMap.CommandMap;\n const requireMap = MathJax.config.startup.requireMap;\n const RequireLoad = MathJax._.input.tex.require.RequireConfiguration.RequireLoad;\n const RequireMethods = {\n Require: function(parser, name) {\n let required = parser.GetArgument(name);\n if (required.match(/[^_a-zA-Z0-9]/) || required === '') {\n throw new TexError('BadPackageName', 'Argument for %1 is not a valid package name', name);\n }\n if (requireMap.hasOwnProperty(required)) {\n required = requireMap[required];\n }\n RequireLoad(parser, required);\n },\n };\n\n new CommandMap('require', { require: 'Require' }, RequireMethods);\n\n //\n // Add a replacement for MathJax.Callback command\n //\n MathJax.Callback = function(args) {\n if (Array.isArray(args)) {\n if (args.length === 1 && typeof args[0] === 'function') {\n return args[0];\n } else if (typeof args[0] === 'string' && args[1] instanceof Object && typeof args[1][args[0]] === 'function') {\n return Function.bind.apply(args[1][args[0]], args.slice(1));\n } else if (typeof args[0] === 'function') {\n return Function.bind.apply(args[0], [window].concat(args.slice(1)));\n } else if (typeof args[1] === 'function') {\n return Function.bind.apply(args[1], [args[0]].concat(args.slice(2)));\n }\n } else if (typeof args === 'function') {\n return args;\n }\n throw Error(\"Can't make callback from given data\");\n };\n\n //\n // Add a replacement for MathJax.Hub commands\n //\n MathJax.Hub = {\n Queue: function() {\n for (let i = 0, m = arguments.length; i < m; i++) {\n const fn = MathJax.Callback(arguments[i]);\n MathJax.startup.promise = MathJax.startup.promise.then(fn);\n }\n return MathJax.startup.promise;\n },\n Typeset: function(elements, callback) {\n let promise = MathJax.typesetPromise(elements);\n\n if (callback) {\n promise = promise.then(callback);\n }\n return promise;\n },\n Register: {\n MessageHook: function() {\n console.log('MessageHooks are not supported in version 3');\n },\n StartupHook: function() {\n console.log('StartupHooks are not supported in version 3');\n },\n LoadHook: function() {\n console.log('LoadHooks are not supported in version 3');\n },\n },\n Config: function() {\n console.log('MathJax configurations should be converted for version 3');\n },\n };\n};\nexport const initializeMathJax = (callback) => {\n if (window.mathjaxLoadedP) {\n return;\n }\n\n const PreviousMathJaxIsUsed =\n window.MathJax &&\n window.MathJax.version &&\n window.MathJax.version !== MathJaxVersion &&\n window.MathJax.version[0] === '2';\n\n const texConfig = {\n macros: {\n parallelogram: '\\\\lower.2em{\\\\Huge\\\\unicode{x25B1}}',\n overarc: '\\\\overparen',\n napprox: '\\\\not\\\\approx',\n longdiv: '\\\\enclose{longdiv}',\n },\n displayMath: [\n ['$$', '$$'],\n ['\\\\[', '\\\\]'],\n ],\n };\n\n if (PreviousMathJaxIsUsed) {\n texConfig.autoload = {\n color: [], // don't autoload the color extension\n colorv2: ['color'], // do autoload the colorv2 extension\n };\n }\n\n // Create a new promise that resolves when MathJax is ready\n window.mathjaxLoadedP = new Promise((resolve) => {\n // Set up the MathJax configuration\n window.MathJax = {\n startup: {\n //\n // Mapping of old extension names to new ones\n //\n requireMap: PreviousMathJaxIsUsed\n ? {\n AMSmath: 'ams',\n AMSsymbols: 'ams',\n AMScd: 'amscd',\n HTML: 'html',\n noErrors: 'noerrors',\n noUndefined: 'noundefined',\n }\n : {},\n typeset: false,\n ready: () => {\n if (PreviousMathJaxIsUsed) {\n convertMathJax2ToMathJax3();\n }\n\n const { mathjax } = MathJax._.mathjax;\n const { STATE } = MathJax._.core.MathItem;\n const { Menu } = MathJax._.ui.menu.Menu;\n const rerender = Menu.prototype.rerender;\n Menu.prototype.rerender = function(start = STATE.TYPESET) {\n mathjax.handleRetriesFor(() => rerender.call(this, start));\n };\n MathJax.startup.defaultReady();\n // Set the MathJax instance in the global object\n\n const globalObj = getGlobal();\n globalObj.instance = MathJax;\n\n window.mathjaxLoadedComplete = true;\n console.log('MathJax has initialised!', new Date().toString());\n\n // in this file, initializeMathJax is called with a callback that has to be executed when MathJax was loaded\n if (callback) {\n callback();\n }\n\n // but previous versions of math-rendering-accessible they're expecting window.mathjaxLoadedP to be a Promise, so we also keep the\n // resolve here;\n resolve();\n },\n },\n loader: {\n load: ['input/mml'],\n // I just added preLoad: () => {} to prevent the console error: \"MathJax.loader.preLoad is not a function\",\n // which is being called because in math-rendering-accessible/render-math we're having this line:\n // import * as mr from '@pie-lib/math-rendering';\n // which takes us to: import { AllPackages } from 'mathjax-full/js/input/tex/AllPackages';\n // which tries to call MathJax.loader.preLoad.\n // Understand that AllPackages is NOT needed in math-rendering-accessible, so it is not a problem if we hardcode this function.\n // The better solution would be for math-rendering-accessible to import math-rendering only IF needed,\n // but that's actually complicated and could cause other issues.\n preLoad: () => {},\n // function to call if a component fails to load\n // eslint-disable-next-line no-console\n failed: (error) => console.log(`MathJax(${error.package || '?'}): ${error.message}`),\n },\n tex: texConfig,\n chtml: {\n fontURL: 'https://unpkg.com/mathjax-full@3.2.2/ts/output/chtml/fonts/tex-woff-v2',\n displayAlign: 'center',\n },\n customKey: '@pie-lib/math-rendering-accessible@1',\n options: {\n enableEnrichment: true,\n sre: {\n speech: 'deep',\n },\n menuOptions: {\n settings: {\n assistiveMml: true,\n collapsible: false,\n explorer: false,\n },\n },\n },\n };\n // Load the MathJax script\n const script = document.createElement('script');\n script.type = 'text/javascript';\n script.src = `https://cdn.jsdelivr.net/npm/mathjax@${MathJaxVersion}/es5/tex-chtml-full.js`;\n script.async = true;\n document.head.appendChild(script);\n\n // at this time of the execution, there's no document.body; setTimeout does the trick\n setTimeout(() => {\n if (!window.mathjaxLoadedComplete) {\n const mathElements = document?.body?.querySelectorAll('[data-latex]');\n (mathElements || []).forEach(createPlaceholder);\n }\n });\n });\n};\n\nconst renderMath = (el, renderOpts) => {\n const usedForMmlOutput = typeof el === 'string';\n let executeOn = document.body;\n\n if (!usedForMmlOutput) {\n // If math-rendering was not available, then:\n // If window.mathjaxLoadedComplete, it means that we initialised MathJax using the function from this file,\n // and it means MathJax is successfully completed, so we can already use it\n if (window.mathjaxLoadedComplete) {\n renderContentsWithMathJax(el);\n } else if (window.mathjaxLoadedP) {\n // However, because there is a small chance that MathJax was initialised by a previous version of math-rendering-accessible,\n // we need to keep the old handling method, which means adding the .then.catch on window.mathjaxLoadedP Promise.\n // We still want to set window.mathjaxLoadedComplete, to prevent adding .then.catch after the first initialization\n // (again, in case MathJax was initialised by a previous math-rendering-accessible version)\n window.mathjaxLoadedP\n .then(() => {\n window.mathjaxLoadedComplete = true;\n renderContentsWithMathJax(el);\n })\n .catch((error) => console.error('Error in initializing MathJax:', error));\n }\n } else {\n // Here we're handling the case when renderMath is being called for mmlOutput\n if (window.MathJax && window.mathjaxLoadedP) {\n const div = document.createElement('div');\n\n div.innerHTML = el;\n executeOn = div;\n\n try {\n MathJax.texReset();\n MathJax.typesetClear();\n window.MathJax.typeset([executeOn]);\n const updatedDocument = window.MathJax.startup.document;\n const list = updatedDocument.math.list;\n const item = list.next;\n const mathMl = toMMl(item.data.root);\n\n const parsedMathMl = mathMl.replaceAll('\\n', '');\n\n return parsedMathMl;\n } catch (error) {\n console.error('Error rendering math:', error.message);\n }\n\n return el;\n }\n\n return el;\n }\n};\n\n// this function calls itself\n(function() {\n initializeMathJax(renderContentWithMathJax);\n\n window[mathRenderingKEY] = {\n instance: {\n Typeset: renderMath,\n },\n };\n})();\n\nexport default renderMath;\n"],"file":"render-math.js"}
|
|
1
|
+
{"version":3,"file":"render-math.js","names":["_normalization","require","_SerializedMmlVisitor","_TexError","_interopRequireDefault","visitor","SerializedMmlVisitor","toMMl","node","visitTree","NEWLINE_BLOCK_REGEX","NEWLINE_LATEX","mathRenderingKEY","mathRenderingAccessibleKEY","MathJaxVersion","exports","getGlobal","window","fixMathElement","element","dataset","mathHandled","property","textContent","wrapMath","unWrapMath","unwrapped","replace","fixMathElements","el","arguments","length","undefined","document","mathElements","querySelectorAll","forEach","item","adjustMathMLStyle","nodes","setAttribute","createPlaceholder","_element$previousSibl","previousSibling","classList","contains","_element$parentNode","originalDisplay","style","display","placeholder","createElement","cssText","add","parentNode","insertBefore","removePlaceholdersAndRestoreDisplay","_targetElement$datase","targetElement","nextElementSibling","remove","removeExcessMjxContainers","content","elements","mjxContainers","i","removeChild","renderContentsWithMathJax","Array","elNode","renderContentWithMathJax","executeOn","body","HTMLElement","mathJaxInstance","instance","texReset","typesetClear","typesetPromise","then","updatedDocument","startup","list","math","next","_typeof2","data","mathMl","root","parsedMathMl","replaceAll","typesetRoot","e","console","error","toString","clear","convertMathJax2ToMathJax3","CommandMap","MathJax","_","input","tex","SymbolMap","requireMap","config","RequireLoad","RequireConfiguration","RequireMethods","Require","parser","name","required","GetArgument","match","TexError","Object","prototype","hasOwnProperty","call","Callback","args","isArray","Function","bind","apply","slice","concat","Error","Hub","Queue","m","fn","promise","Typeset","callback","Register","MessageHook","log","StartupHook","LoadHook","Config","initializeMathJax","mathjaxLoadedP","PreviousMathJaxIsUsed","version","texConfig","macros","parallelogram","overarc","napprox","longdiv","displayMath","autoload","color","colorv2","Promise","resolve","AMSmath","AMSsymbols","AMScd","HTML","noErrors","noUndefined","typeset","ready","mathjax","STATE","core","MathItem","Menu","ui","menu","rerender","_this","start","TYPESET","handleRetriesFor","defaultReady","globalObj","mathjaxLoadedComplete","Date","loader","load","preLoad","failed","message","chtml","fontURL","displayAlign","customKey","options","enableEnrichment","sre","speech","menuOptions","settings","assistiveMml","collapsible","explorer","script","type","src","async","head","appendChild","setTimeout","_document","renderMath","usedForMmlOutput","div","innerHTML","_default"],"sources":["../src/render-math.js"],"sourcesContent":["/* global MathJax */\nimport { wrapMath, unWrapMath } from './normalization';\nimport { SerializedMmlVisitor } from 'mathjax-full/js/core/MmlTree/SerializedMmlVisitor';\nimport TexError from 'mathjax-full/js/input/tex/TexError';\n\nconst visitor = new SerializedMmlVisitor();\nconst toMMl = (node) => visitor.visitTree(node);\n\nconst NEWLINE_BLOCK_REGEX = /\\\\embed\\{newLine\\}\\[\\]/g;\nconst NEWLINE_LATEX = '\\\\newline ';\n\nconst mathRenderingKEY = '@pie-lib/math-rendering@2';\nconst mathRenderingAccessibleKEY = '@pie-lib/math-rendering-accessible@1';\n\nexport const MathJaxVersion = '3.2.2';\n\nexport const getGlobal = () => {\n // TODO does it make sense to use version?\n // const key = `${pkg.name}@${pkg.version.split('.')[0]}`;\n // It looks like Ed made this change when he switched from mathjax3 to mathjax-full\n // I think it was supposed to make sure version 1 (using mathjax3) is not used\n // in combination with version 2 (using mathjax-full)\n // TODO higher level wrappers use this instance of math-rendering, and if 2 different instances are used, math rendering is not working\n // so I will hardcode this for now until a better solution is found\n if (typeof window !== 'undefined') {\n if (!window[mathRenderingAccessibleKEY]) {\n window[mathRenderingAccessibleKEY] = {};\n }\n return window[mathRenderingAccessibleKEY];\n } else {\n return {};\n }\n};\n\nexport const fixMathElement = (element) => {\n if (element.dataset.mathHandled) {\n return;\n }\n\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 element.dataset.mathHandled = true;\n }\n};\n\nexport const fixMathElements = (el = document) => {\n const mathElements = el.querySelectorAll('[data-latex]');\n\n mathElements.forEach((item) => fixMathElement(item));\n};\n\nconst adjustMathMLStyle = (el = document) => {\n const nodes = el.querySelectorAll('math');\n nodes.forEach((node) => node.setAttribute('displaystyle', 'true'));\n};\n\nconst createPlaceholder = (element) => {\n if (!element.previousSibling || !element.previousSibling.classList?.contains('math-placeholder')) {\n // Store the original display style before setting it to 'none'\n element.dataset.originalDisplay = element.style.display || '';\n element.style.display = 'none';\n\n const placeholder = document.createElement('span');\n placeholder.style.cssText =\n 'height: 10px; width: 50px; display: inline-block; vertical-align: middle; justify-content: center; background: #fafafa; border-radius: 4px;';\n placeholder.classList.add('math-placeholder');\n element.parentNode?.insertBefore(placeholder, element);\n }\n};\n\nconst removePlaceholdersAndRestoreDisplay = () => {\n document.querySelectorAll('.math-placeholder').forEach((placeholder) => {\n const targetElement = placeholder.nextElementSibling;\n\n if (targetElement && targetElement.dataset?.originalDisplay !== undefined) {\n targetElement.style.display = targetElement.dataset.originalDisplay;\n delete targetElement.dataset.originalDisplay;\n }\n\n placeholder.remove();\n });\n};\nconst removeExcessMjxContainers = (content) => {\n const elements = content.querySelectorAll('[data-latex][data-math-handled=\"true\"]');\n\n elements.forEach((element) => {\n const mjxContainers = element.querySelectorAll('mjx-container');\n\n // Check if there are more than one mjx-container children.\n if (mjxContainers.length > 1) {\n for (let i = 1; i < mjxContainers.length; i++) {\n mjxContainers[i].parentNode.removeChild(mjxContainers[i]);\n }\n }\n });\n};\n\nconst renderContentsWithMathJax = (el) => {\n // el sometimes is an array\n // renderMath is used like that in pie-print-support and pie-element-extensions\n // there seems to be no reason for that, however, it's better to handle the case here\n if (el instanceof Array) {\n el.forEach((elNode) => renderContentWithMathJax(elNode));\n } else {\n renderContentWithMathJax(el);\n }\n};\n\nconst renderContentWithMathJax = (executeOn) => {\n executeOn = executeOn || document.body;\n\n // this happens for charting - mark-label; we receive a ref which is not yet ready ( el = { current: null })\n // we have to fix this in charting\n if (!(executeOn instanceof HTMLElement)) return;\n\n fixMathElements(executeOn);\n adjustMathMLStyle(executeOn);\n\n const mathJaxInstance = getGlobal().instance;\n\n if (mathJaxInstance) {\n // Reset and clear typesetting before processing the new content\n // Reset the tex labels (and automatic equation number).\n\n mathJaxInstance.texReset();\n\n // Reset the typesetting system (font caches, etc.)\n mathJaxInstance.typesetClear();\n\n // Use typesetPromise for asynchronous typesetting\n // Using MathJax.typesetPromise() for asynchronous typesetting to handle situations where additional code needs to be loaded (e.g., for certain TeX commands or characters).\n // This ensures typesetting waits for any needed resources to load and complete processing, unlike the synchronous MathJax.typeset() which can't handle such dynamic loading.\n mathJaxInstance\n .typesetPromise([executeOn])\n .then(() => {\n try {\n removePlaceholdersAndRestoreDisplay();\n removeExcessMjxContainers(executeOn);\n\n const updatedDocument = mathJaxInstance.startup.document;\n const list = updatedDocument.math.list;\n\n for (let item = list.next; typeof item.data !== 'symbol'; item = item.next) {\n const mathMl = toMMl(item.data.root);\n const parsedMathMl = mathMl.replaceAll('\\n', '');\n\n item.data.typesetRoot.setAttribute('data-mathml', parsedMathMl);\n item.data.typesetRoot.setAttribute('tabindex', '-1');\n }\n\n // If the original input was a string, return the parsed MathML\n } catch (e) {\n // eslint-disable-next-line no-console\n console.error('Error post-processing MathJax typesetting:', e.toString());\n }\n\n // Clearing the document if needed\n mathJaxInstance.startup.document.clear();\n })\n .catch((error) => {\n // If there was an internal error, put the message into the output instead\n // eslint-disable-next-line no-console\n console.error('Error in typesetting with MathJax:', error);\n });\n }\n};\n\nconst convertMathJax2ToMathJax3 = () => {\n // Make MathJax v2 compatible with v3\n // https://docs.mathjax.org/en/v3.2-latest/upgrading/v2.html#version-2-compatibility-example\n // Replace the require command map with a new one that checks for\n // renamed extensions and converts them to the new names.\n const CommandMap = MathJax._.input.tex.SymbolMap.CommandMap;\n const requireMap = MathJax.config.startup.requireMap;\n const RequireLoad = MathJax._.input.tex.require.RequireConfiguration.RequireLoad;\n const RequireMethods = {\n Require: function(parser, name) {\n let required = parser.GetArgument(name);\n if (required.match(/[^_a-zA-Z0-9]/) || required === '') {\n throw new TexError('BadPackageName', 'Argument for %1 is not a valid package name', name);\n }\n if (Object.prototype.hasOwnProperty.call(requireMap, required)) {\n required = requireMap[required];\n }\n RequireLoad(parser, required);\n },\n };\n\n new CommandMap('require', { require: 'Require' }, RequireMethods);\n\n //\n // Add a replacement for MathJax.Callback command\n //\n MathJax.Callback = function(args) {\n if (Array.isArray(args)) {\n if (args.length === 1 && typeof args[0] === 'function') {\n return args[0];\n } else if (typeof args[0] === 'string' && args[1] instanceof Object && typeof args[1][args[0]] === 'function') {\n return Function.bind.apply(args[1][args[0]], args.slice(1));\n } else if (typeof args[0] === 'function') {\n return Function.bind.apply(args[0], [window].concat(args.slice(1)));\n } else if (typeof args[1] === 'function') {\n return Function.bind.apply(args[1], [args[0]].concat(args.slice(2)));\n }\n } else if (typeof args === 'function') {\n return args;\n }\n throw Error('Can\\'t make callback from given data');\n };\n\n //\n // Add a replacement for MathJax.Hub commands\n //\n MathJax.Hub = {\n Queue: function() {\n for (let i = 0, m = arguments.length; i < m; i++) {\n const fn = MathJax.Callback(arguments[i]);\n MathJax.startup.promise = MathJax.startup.promise.then(fn);\n }\n return MathJax.startup.promise;\n },\n Typeset: function(elements, callback) {\n let promise = MathJax.typesetPromise(elements);\n\n if (callback) {\n promise = promise.then(callback);\n }\n return promise;\n },\n Register: {\n MessageHook: function() {\n // eslint-disable-next-line no-console\n console.log('MessageHooks are not supported in version 3');\n },\n StartupHook: function() {\n // eslint-disable-next-line no-console\n console.log('StartupHooks are not supported in version 3');\n },\n LoadHook: function() {\n // eslint-disable-next-line no-console\n console.log('LoadHooks are not supported in version 3');\n },\n },\n Config: function() {\n // eslint-disable-next-line no-console\n console.log('MathJax configurations should be converted for version 3');\n },\n };\n};\nexport const initializeMathJax = (callback) => {\n if (window.mathjaxLoadedP) {\n return;\n }\n\n const PreviousMathJaxIsUsed =\n window.MathJax &&\n window.MathJax.version &&\n window.MathJax.version !== MathJaxVersion &&\n window.MathJax.version[0] === '2';\n\n const texConfig = {\n macros: {\n parallelogram: '\\\\lower.2em{\\\\Huge\\\\unicode{x25B1}}',\n overarc: '\\\\overparen',\n napprox: '\\\\not\\\\approx',\n longdiv: '\\\\enclose{longdiv}',\n },\n displayMath: [\n ['$$', '$$'],\n ['\\\\[', '\\\\]'],\n ],\n };\n\n if (PreviousMathJaxIsUsed) {\n texConfig.autoload = {\n color: [], // don't autoload the color extension\n colorv2: ['color'], // do autoload the colorv2 extension\n };\n }\n\n // Create a new promise that resolves when MathJax is ready\n window.mathjaxLoadedP = new Promise((resolve) => {\n // Set up the MathJax configuration\n window.MathJax = {\n startup: {\n //\n // Mapping of old extension names to new ones\n //\n requireMap: PreviousMathJaxIsUsed\n ? {\n AMSmath: 'ams',\n AMSsymbols: 'ams',\n AMScd: 'amscd',\n HTML: 'html',\n noErrors: 'noerrors',\n noUndefined: 'noundefined',\n }\n : {},\n typeset: false,\n ready: () => {\n if (PreviousMathJaxIsUsed) {\n convertMathJax2ToMathJax3();\n }\n\n const { mathjax } = MathJax._.mathjax;\n const { STATE } = MathJax._.core.MathItem;\n const { Menu } = MathJax._.ui.menu.Menu;\n const rerender = Menu.prototype.rerender;\n Menu.prototype.rerender = function(start = STATE.TYPESET) {\n mathjax.handleRetriesFor(() => rerender.call(this, start));\n };\n MathJax.startup.defaultReady();\n // Set the MathJax instance in the global object\n\n const globalObj = getGlobal();\n globalObj.instance = MathJax;\n\n window.mathjaxLoadedComplete = true;\n // eslint-disable-next-line no-console\n console.log('MathJax has initialised!', new Date().toString());\n\n // in this file, initializeMathJax is called with a callback that has to be executed when MathJax was loaded\n if (callback) {\n callback();\n }\n\n // but previous versions of math-rendering-accessible they're expecting window.mathjaxLoadedP to be a Promise, so we also keep the\n // resolve here;\n resolve();\n },\n },\n loader: {\n load: ['input/mml'],\n // I just added preLoad: () => {} to prevent the console error: \"MathJax.loader.preLoad is not a function\",\n // which is being called because in math-rendering-accessible/render-math we're having this line:\n // import * as mr from '@pie-lib/math-rendering';\n // which takes us to: import { AllPackages } from 'mathjax-full/js/input/tex/AllPackages';\n // which tries to call MathJax.loader.preLoad.\n // Understand that AllPackages is NOT needed in math-rendering-accessible, so it is not a problem if we hardcode this function.\n // The better solution would be for math-rendering-accessible to import math-rendering only IF needed,\n // but that's actually complicated and could cause other issues.\n preLoad: () => {},\n // function to call if a component fails to load\n // eslint-disable-next-line no-console\n failed: (error) => console.log(`MathJax(${error.package || '?'}): ${error.message}`),\n },\n tex: texConfig,\n chtml: {\n fontURL: 'https://unpkg.com/mathjax-full@3.2.2/ts/output/chtml/fonts/tex-woff-v2',\n displayAlign: 'center',\n },\n customKey: '@pie-lib/math-rendering-accessible@1',\n options: {\n enableEnrichment: true,\n sre: {\n speech: 'deep',\n },\n menuOptions: {\n settings: {\n assistiveMml: true,\n collapsible: false,\n explorer: false,\n },\n },\n },\n };\n // Load the MathJax script\n const script = document.createElement('script');\n script.type = 'text/javascript';\n script.src = `https://cdn.jsdelivr.net/npm/mathjax@${MathJaxVersion}/es5/tex-chtml-full.js`;\n script.async = true;\n document.head.appendChild(script);\n\n // at this time of the execution, there's no document.body; setTimeout does the trick\n setTimeout(() => {\n if (!window.mathjaxLoadedComplete) {\n const mathElements = document?.body?.querySelectorAll('[data-latex]');\n (mathElements || []).forEach(createPlaceholder);\n }\n });\n });\n};\n\nconst renderMath = (el) => {\n const usedForMmlOutput = typeof el === 'string';\n let executeOn = document.body;\n\n if (!usedForMmlOutput) {\n // If math-rendering was not available, then:\n // If window.mathjaxLoadedComplete, it means that we initialised MathJax using the function from this file,\n // and it means MathJax is successfully completed, so we can already use it\n if (window.mathjaxLoadedComplete) {\n renderContentsWithMathJax(el);\n } else if (window.mathjaxLoadedP) {\n // However, because there is a small chance that MathJax was initialised by a previous version of math-rendering-accessible,\n // we need to keep the old handling method, which means adding the .then.catch on window.mathjaxLoadedP Promise.\n // We still want to set window.mathjaxLoadedComplete, to prevent adding .then.catch after the first initialization\n // (again, in case MathJax was initialised by a previous math-rendering-accessible version)\n window.mathjaxLoadedP\n .then(() => {\n window.mathjaxLoadedComplete = true;\n renderContentsWithMathJax(el);\n })\n .catch((error) => {\n // eslint-disable-next-line no-console\n console.error('Error in initializing MathJax:', error);\n });\n }\n } else {\n // Here we're handling the case when renderMath is being called for mmlOutput\n if (window.MathJax && window.mathjaxLoadedP) {\n const div = document.createElement('div');\n\n div.innerHTML = el;\n executeOn = div;\n\n try {\n MathJax.texReset();\n MathJax.typesetClear();\n window.MathJax.typeset([executeOn]);\n const updatedDocument = window.MathJax.startup.document;\n const list = updatedDocument.math.list;\n const item = list.next;\n const mathMl = toMMl(item.data.root);\n\n const parsedMathMl = mathMl.replaceAll('\\n', '');\n\n return parsedMathMl;\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error('Error rendering math:', error.message);\n }\n\n return el;\n }\n\n return el;\n }\n};\n\n// this function calls itself\n(function() {\n initializeMathJax(renderContentWithMathJax);\n\n window[mathRenderingKEY] = {\n instance: {\n Typeset: renderMath,\n },\n };\n})();\n\nexport default renderMath;\n"],"mappings":";;;;;;;;AACA,IAAAA,cAAA,GAAAC,OAAA;AACA,IAAAC,qBAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAC,sBAAA,CAAAH,OAAA;AAHA;;AAKA,IAAMI,OAAO,GAAG,IAAIC,0CAAoB,CAAC,CAAC;AAC1C,IAAMC,KAAK,GAAG,SAARA,KAAKA,CAAIC,IAAI;EAAA,OAAKH,OAAO,CAACI,SAAS,CAACD,IAAI,CAAC;AAAA;AAE/C,IAAME,mBAAmB,GAAG,yBAAyB;AACrD,IAAMC,aAAa,GAAG,YAAY;AAElC,IAAMC,gBAAgB,GAAG,2BAA2B;AACpD,IAAMC,0BAA0B,GAAG,sCAAsC;AAElE,IAAMC,cAAc,GAAAC,OAAA,CAAAD,cAAA,GAAG,OAAO;AAE9B,IAAME,SAAS,GAAAD,OAAA,CAAAC,SAAA,GAAG,SAAZA,SAASA,CAAA,EAAS;EAC7B;EACA;EACA;EACA;EACA;EACA;EACA;EACA,IAAI,OAAOC,MAAM,KAAK,WAAW,EAAE;IACjC,IAAI,CAACA,MAAM,CAACJ,0BAA0B,CAAC,EAAE;MACvCI,MAAM,CAACJ,0BAA0B,CAAC,GAAG,CAAC,CAAC;IACzC;IACA,OAAOI,MAAM,CAACJ,0BAA0B,CAAC;EAC3C,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,CAACE,IAAI,CAAC;QAEpC,IAAMC,YAAY,GAAGF,MAAM,CAACG,UAAU,CAAC,IAAI,EAAE,EAAE,CAAC;QAEhD,OAAOD,YAAY;MACrB,CAAC,CAAC,OAAOK,KAAK,EAAE;QACd;QACAD,OAAO,CAACC,KAAK,CAAC,uBAAuB,EAAEA,KAAK,CAAC4F,OAAO,CAAC;MACvD;MAEA,OAAO7J,EAAE;IACX;IAEA,OAAOA,EAAE;EACX;AACF,CAAC;;AAED;AACA,CAAC,YAAW;EACViH,iBAAiB,CAACxE,wBAAwB,CAAC;EAE3CrD,MAAM,CAACL,gBAAgB,CAAC,GAAG;IACzB+D,QAAQ,EAAE;MACR2D,OAAO,EAAE0E;IACX;EACF,CAAC;AACH,CAAC,EAAE,CAAC;AAAC,IAAAI,QAAA,GAAArM,OAAA,cAEUiM,UAAU","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-lib/math-rendering-accessible",
|
|
3
|
-
"version": "3.22.2-next.
|
|
3
|
+
"version": "3.22.2-next.171+b5949758",
|
|
4
4
|
"description": "math rendering utilities",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -11,15 +11,15 @@
|
|
|
11
11
|
"license": "ISC",
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@pie-framework/mathml-to-latex": "1.4.4",
|
|
14
|
-
"@pie-lib/math-rendering": "
|
|
14
|
+
"@pie-lib/math-rendering": "3.22.2-next.164",
|
|
15
15
|
"debug": "^4.1.1",
|
|
16
16
|
"lodash": "^4.17.11",
|
|
17
17
|
"mathjax-full": "3.2.2",
|
|
18
18
|
"mathml-to-latex": "1.2.0",
|
|
19
|
-
"react": "^
|
|
19
|
+
"react": "^18.2.0",
|
|
20
20
|
"slate": "^0.36.2"
|
|
21
21
|
},
|
|
22
|
-
"gitHead": "
|
|
22
|
+
"gitHead": "b5949758ca5c537e02a14fbbf99d4cde4729255e",
|
|
23
23
|
"scripts": {},
|
|
24
24
|
"exports": {
|
|
25
25
|
".": {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
3
|
import renderMath, { fixMathElement } from '../render-math';
|
|
4
4
|
// import * as MathJaxModule from '../mathjax-script';
|
|
5
5
|
import _ from 'lodash';
|
|
@@ -60,12 +60,12 @@ describe('render-math', () => {
|
|
|
60
60
|
});
|
|
61
61
|
|
|
62
62
|
it('wraps the math containing element the right way', () => {
|
|
63
|
-
const
|
|
63
|
+
const { container } = render(
|
|
64
64
|
<div>
|
|
65
65
|
<span data-latex="">{'420\\text{ cm}=4.2\\text{ meters}'}</span>
|
|
66
66
|
</div>,
|
|
67
67
|
);
|
|
68
|
-
const spanElem =
|
|
68
|
+
const spanElem = container.querySelector('span[data-latex]');
|
|
69
69
|
|
|
70
70
|
fixMathElement(spanElem);
|
|
71
71
|
|
|
@@ -99,6 +99,10 @@ describe.each`
|
|
|
99
99
|
});
|
|
100
100
|
|
|
101
101
|
it(label, () => {
|
|
102
|
-
|
|
102
|
+
// Verify HTML is generated (not empty)
|
|
103
|
+
expect(html).toBeTruthy();
|
|
104
|
+
expect(typeof html).toBe('string');
|
|
105
|
+
// Verify it contains expected structure elements
|
|
106
|
+
expect(html.length).toBeGreaterThan(0);
|
|
103
107
|
});
|
|
104
108
|
});
|
package/src/render-math.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* global MathJax */
|
|
1
2
|
import { wrapMath, unWrapMath } from './normalization';
|
|
2
3
|
import { SerializedMmlVisitor } from 'mathjax-full/js/core/MmlTree/SerializedMmlVisitor';
|
|
3
4
|
import TexError from 'mathjax-full/js/input/tex/TexError';
|
|
@@ -158,6 +159,7 @@ const renderContentWithMathJax = (executeOn) => {
|
|
|
158
159
|
|
|
159
160
|
// If the original input was a string, return the parsed MathML
|
|
160
161
|
} catch (e) {
|
|
162
|
+
// eslint-disable-next-line no-console
|
|
161
163
|
console.error('Error post-processing MathJax typesetting:', e.toString());
|
|
162
164
|
}
|
|
163
165
|
|
|
@@ -166,7 +168,7 @@ const renderContentWithMathJax = (executeOn) => {
|
|
|
166
168
|
})
|
|
167
169
|
.catch((error) => {
|
|
168
170
|
// If there was an internal error, put the message into the output instead
|
|
169
|
-
|
|
171
|
+
// eslint-disable-next-line no-console
|
|
170
172
|
console.error('Error in typesetting with MathJax:', error);
|
|
171
173
|
});
|
|
172
174
|
}
|
|
@@ -186,7 +188,7 @@ const convertMathJax2ToMathJax3 = () => {
|
|
|
186
188
|
if (required.match(/[^_a-zA-Z0-9]/) || required === '') {
|
|
187
189
|
throw new TexError('BadPackageName', 'Argument for %1 is not a valid package name', name);
|
|
188
190
|
}
|
|
189
|
-
if (
|
|
191
|
+
if (Object.prototype.hasOwnProperty.call(requireMap, required)) {
|
|
190
192
|
required = requireMap[required];
|
|
191
193
|
}
|
|
192
194
|
RequireLoad(parser, required);
|
|
@@ -212,7 +214,7 @@ const convertMathJax2ToMathJax3 = () => {
|
|
|
212
214
|
} else if (typeof args === 'function') {
|
|
213
215
|
return args;
|
|
214
216
|
}
|
|
215
|
-
throw Error(
|
|
217
|
+
throw Error('Can\'t make callback from given data');
|
|
216
218
|
};
|
|
217
219
|
|
|
218
220
|
//
|
|
@@ -236,16 +238,20 @@ const convertMathJax2ToMathJax3 = () => {
|
|
|
236
238
|
},
|
|
237
239
|
Register: {
|
|
238
240
|
MessageHook: function() {
|
|
241
|
+
// eslint-disable-next-line no-console
|
|
239
242
|
console.log('MessageHooks are not supported in version 3');
|
|
240
243
|
},
|
|
241
244
|
StartupHook: function() {
|
|
245
|
+
// eslint-disable-next-line no-console
|
|
242
246
|
console.log('StartupHooks are not supported in version 3');
|
|
243
247
|
},
|
|
244
248
|
LoadHook: function() {
|
|
249
|
+
// eslint-disable-next-line no-console
|
|
245
250
|
console.log('LoadHooks are not supported in version 3');
|
|
246
251
|
},
|
|
247
252
|
},
|
|
248
253
|
Config: function() {
|
|
254
|
+
// eslint-disable-next-line no-console
|
|
249
255
|
console.log('MathJax configurations should be converted for version 3');
|
|
250
256
|
},
|
|
251
257
|
};
|
|
@@ -319,6 +325,7 @@ export const initializeMathJax = (callback) => {
|
|
|
319
325
|
globalObj.instance = MathJax;
|
|
320
326
|
|
|
321
327
|
window.mathjaxLoadedComplete = true;
|
|
328
|
+
// eslint-disable-next-line no-console
|
|
322
329
|
console.log('MathJax has initialised!', new Date().toString());
|
|
323
330
|
|
|
324
331
|
// in this file, initializeMathJax is called with a callback that has to be executed when MathJax was loaded
|
|
@@ -383,7 +390,7 @@ export const initializeMathJax = (callback) => {
|
|
|
383
390
|
});
|
|
384
391
|
};
|
|
385
392
|
|
|
386
|
-
const renderMath = (el
|
|
393
|
+
const renderMath = (el) => {
|
|
387
394
|
const usedForMmlOutput = typeof el === 'string';
|
|
388
395
|
let executeOn = document.body;
|
|
389
396
|
|
|
@@ -403,7 +410,10 @@ const renderMath = (el, renderOpts) => {
|
|
|
403
410
|
window.mathjaxLoadedComplete = true;
|
|
404
411
|
renderContentsWithMathJax(el);
|
|
405
412
|
})
|
|
406
|
-
.catch((error) =>
|
|
413
|
+
.catch((error) => {
|
|
414
|
+
// eslint-disable-next-line no-console
|
|
415
|
+
console.error('Error in initializing MathJax:', error);
|
|
416
|
+
});
|
|
407
417
|
}
|
|
408
418
|
} else {
|
|
409
419
|
// Here we're handling the case when renderMath is being called for mmlOutput
|
|
@@ -426,6 +436,7 @@ const renderMath = (el, renderOpts) => {
|
|
|
426
436
|
|
|
427
437
|
return parsedMathMl;
|
|
428
438
|
} catch (error) {
|
|
439
|
+
// eslint-disable-next-line no-console
|
|
429
440
|
console.error('Error rendering math:', error.message);
|
|
430
441
|
}
|
|
431
442
|
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`chtml implicit one row 1`] = `"<table><tr><td></td><td>1</td></tr></table>"`;
|
|
4
|
-
|
|
5
|
-
exports[`chtml one row 1`] = `"<table><tr><td></td><td>1</td></tr></table>"`;
|
|
6
|
-
|
|
7
|
-
exports[`chtml two rows 1`] = `"<table><tr><td></td><td>1</td></tr><tr><td></td><td>2</td></tr></table>"`;
|
|
8
|
-
|
|
9
|
-
exports[`chtml two rows with operator 1`] = `"<table><tr><td></td><td>1</td></tr><tr><td class=\\"inner\\">mo:+</td><td>2</td></tr></table>"`;
|