@pie-element/ebsr 11.0.0 → 12.0.1-esmbeta.1
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 +22 -0
- package/configure/CHANGELOG.md +8 -0
- package/configure/node_modules/@pie-element/multiple-choice/CHANGELOG.json +1972 -0
- package/configure/node_modules/@pie-element/multiple-choice/CHANGELOG.md +4186 -0
- package/configure/node_modules/@pie-element/multiple-choice/LICENSE.md +5 -0
- package/configure/node_modules/@pie-element/multiple-choice/PRINT.md +35 -0
- package/configure/node_modules/@pie-element/multiple-choice/README.md +56 -0
- package/configure/node_modules/@pie-element/multiple-choice/choice.png +0 -0
- package/configure/node_modules/@pie-element/multiple-choice/configure/CHANGELOG.json +1387 -0
- package/configure/node_modules/@pie-element/multiple-choice/configure/CHANGELOG.md +3332 -0
- package/configure/node_modules/@pie-element/multiple-choice/configure/lib/defaults.js +202 -0
- package/configure/node_modules/@pie-element/multiple-choice/configure/lib/defaults.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/configure/lib/index.js +248 -0
- package/configure/node_modules/@pie-element/multiple-choice/configure/lib/index.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/configure/lib/main.js +597 -0
- package/configure/node_modules/@pie-element/multiple-choice/configure/lib/main.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/configure/lib/utils.js +18 -0
- package/configure/node_modules/@pie-element/multiple-choice/configure/lib/utils.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/configure/package.json +20 -0
- package/configure/node_modules/@pie-element/multiple-choice/controller/CHANGELOG.json +527 -0
- package/configure/node_modules/@pie-element/multiple-choice/controller/CHANGELOG.md +2297 -0
- package/configure/node_modules/@pie-element/multiple-choice/controller/lib/defaults.js +34 -0
- package/configure/node_modules/@pie-element/multiple-choice/controller/lib/defaults.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/controller/lib/index.js +346 -0
- package/configure/node_modules/@pie-element/multiple-choice/controller/lib/index.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/controller/lib/utils.js +28 -0
- package/configure/node_modules/@pie-element/multiple-choice/controller/lib/utils.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/controller/package.json +15 -0
- package/configure/node_modules/@pie-element/multiple-choice/docs/config-schema.json +2993 -0
- package/configure/node_modules/@pie-element/multiple-choice/docs/config-schema.json.md +2217 -0
- package/configure/node_modules/@pie-element/multiple-choice/docs/demo/config.js +8 -0
- package/configure/node_modules/@pie-element/multiple-choice/docs/demo/generate.js +61 -0
- package/configure/node_modules/@pie-element/multiple-choice/docs/demo/index.html +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/docs/demo/session.js +7 -0
- package/configure/node_modules/@pie-element/multiple-choice/docs/pie-schema.json +1332 -0
- package/configure/node_modules/@pie-element/multiple-choice/docs/pie-schema.json.md +1015 -0
- package/configure/node_modules/@pie-element/multiple-choice/esm/configure.css +847 -0
- package/configure/node_modules/@pie-element/multiple-choice/esm/configure.js +1218 -0
- package/configure/node_modules/@pie-element/multiple-choice/esm/configure.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/esm/controller.css +847 -0
- package/configure/node_modules/@pie-element/multiple-choice/esm/controller.js +324 -0
- package/configure/node_modules/@pie-element/multiple-choice/esm/controller.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/esm/element.css +847 -0
- package/configure/node_modules/@pie-element/multiple-choice/esm/element.js +3287 -0
- package/configure/node_modules/@pie-element/multiple-choice/esm/element.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/esm/print.css +847 -0
- package/configure/node_modules/@pie-element/multiple-choice/esm/print.js +3017 -0
- package/configure/node_modules/@pie-element/multiple-choice/esm/print.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/choice-input.js +427 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/choice-input.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/choice.js +252 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/choice.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/feedback-tick.js +174 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/feedback-tick.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/index.js +388 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/index.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/main.js +108 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/main.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/multiple-choice.js +469 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/multiple-choice.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/print.js +129 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/print.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/session-updater.js +48 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/session-updater.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/module/configure.js +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/module/controller.js +3472 -0
- package/configure/node_modules/@pie-element/multiple-choice/module/demo.js +86 -0
- package/configure/node_modules/@pie-element/multiple-choice/module/element.js +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/module/index.html +21 -0
- package/configure/node_modules/@pie-element/multiple-choice/module/index.js +2 -0
- package/configure/node_modules/@pie-element/multiple-choice/module/manifest.json +10 -0
- package/configure/node_modules/@pie-element/multiple-choice/module/print-demo.js +124 -0
- package/configure/node_modules/@pie-element/multiple-choice/module/print.html +18 -0
- package/configure/node_modules/@pie-element/multiple-choice/module/print.js +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/package.json +53 -0
- package/configure/node_modules/@pie-lib/correct-answer-toggle/CHANGELOG.json +1 -0
- package/configure/node_modules/@pie-lib/correct-answer-toggle/CHANGELOG.md +898 -0
- package/configure/node_modules/@pie-lib/correct-answer-toggle/NEXT.CHANGELOG.json +1 -0
- package/configure/node_modules/@pie-lib/correct-answer-toggle/esm/index.js +262 -0
- package/configure/node_modules/@pie-lib/correct-answer-toggle/esm/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/correct-answer-toggle/lib/expander.js +88 -0
- package/configure/node_modules/@pie-lib/correct-answer-toggle/lib/expander.js.map +1 -0
- package/configure/node_modules/@pie-lib/correct-answer-toggle/lib/index.js +181 -0
- package/configure/node_modules/@pie-lib/correct-answer-toggle/lib/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/correct-answer-toggle/lib/styles.js +66 -0
- package/configure/node_modules/@pie-lib/correct-answer-toggle/lib/styles.js.map +1 -0
- package/configure/node_modules/@pie-lib/correct-answer-toggle/package.json +44 -0
- package/configure/node_modules/@pie-lib/correct-answer-toggle/src/__tests__/index.test.jsx +99 -0
- package/configure/node_modules/@pie-lib/correct-answer-toggle/src/expander.jsx +61 -0
- package/configure/node_modules/@pie-lib/correct-answer-toggle/src/index.jsx +98 -0
- package/configure/node_modules/@pie-lib/correct-answer-toggle/src/styles.js +61 -0
- package/configure/node_modules/@pie-lib/icons/CHANGELOG.json +1 -0
- package/configure/node_modules/@pie-lib/icons/CHANGELOG.md +539 -0
- package/configure/node_modules/@pie-lib/icons/NEXT.CHANGELOG.json +1 -0
- package/configure/node_modules/@pie-lib/icons/esm/index.js +1153 -0
- package/configure/node_modules/@pie-lib/icons/esm/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/icons/lib/correct-icon.js +89 -0
- package/configure/node_modules/@pie-lib/icons/lib/correct-icon.js.map +1 -0
- package/configure/node_modules/@pie-lib/icons/lib/correct-response-icon.js +153 -0
- package/configure/node_modules/@pie-lib/icons/lib/correct-response-icon.js.map +1 -0
- package/configure/node_modules/@pie-lib/icons/lib/icon-base.js +206 -0
- package/configure/node_modules/@pie-lib/icons/lib/icon-base.js.map +1 -0
- package/configure/node_modules/@pie-lib/icons/lib/icon-root.js +130 -0
- package/configure/node_modules/@pie-lib/icons/lib/icon-root.js.map +1 -0
- package/configure/node_modules/@pie-lib/icons/lib/incorrect-icon.js +92 -0
- package/configure/node_modules/@pie-lib/icons/lib/incorrect-icon.js.map +1 -0
- package/configure/node_modules/@pie-lib/icons/lib/index.js +72 -0
- package/configure/node_modules/@pie-lib/icons/lib/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/icons/lib/instructions-icon.js +229 -0
- package/configure/node_modules/@pie-lib/icons/lib/instructions-icon.js.map +1 -0
- package/configure/node_modules/@pie-lib/icons/lib/learn-more-icon.js +145 -0
- package/configure/node_modules/@pie-lib/icons/lib/learn-more-icon.js.map +1 -0
- package/configure/node_modules/@pie-lib/icons/lib/nothing-submitted-icon.js +183 -0
- package/configure/node_modules/@pie-lib/icons/lib/nothing-submitted-icon.js.map +1 -0
- package/configure/node_modules/@pie-lib/icons/lib/partially-correct-icon.js +82 -0
- package/configure/node_modules/@pie-lib/icons/lib/partially-correct-icon.js.map +1 -0
- package/configure/node_modules/@pie-lib/icons/lib/show-rationale-icon.js +206 -0
- package/configure/node_modules/@pie-lib/icons/lib/show-rationale-icon.js.map +1 -0
- package/configure/node_modules/@pie-lib/icons/lib/sized.js +41 -0
- package/configure/node_modules/@pie-lib/icons/lib/sized.js.map +1 -0
- package/configure/node_modules/@pie-lib/icons/package.json +35 -0
- package/configure/node_modules/@pie-lib/icons/src/__tests__/index.test.js +3 -0
- package/configure/node_modules/@pie-lib/icons/src/correct-icon.jsx +64 -0
- package/configure/node_modules/@pie-lib/icons/src/correct-response-icon.jsx +121 -0
- package/configure/node_modules/@pie-lib/icons/src/icon-base.jsx +158 -0
- package/configure/node_modules/@pie-lib/icons/src/icon-root.jsx +76 -0
- package/configure/node_modules/@pie-lib/icons/src/incorrect-icon.jsx +61 -0
- package/configure/node_modules/@pie-lib/icons/src/index.js +19 -0
- package/configure/node_modules/@pie-lib/icons/src/instructions-icon.jsx +189 -0
- package/configure/node_modules/@pie-lib/icons/src/learn-more-icon.jsx +107 -0
- package/configure/node_modules/@pie-lib/icons/src/nothing-submitted-icon.jsx +130 -0
- package/configure/node_modules/@pie-lib/icons/src/partially-correct-icon.jsx +49 -0
- package/configure/node_modules/@pie-lib/icons/src/show-rationale-icon.jsx +152 -0
- package/configure/node_modules/@pie-lib/icons/src/sized.jsx +25 -0
- package/configure/node_modules/@pie-lib/math-rendering/CHANGELOG.json +1 -0
- package/configure/node_modules/@pie-lib/math-rendering/CHANGELOG.md +775 -0
- package/configure/node_modules/@pie-lib/math-rendering/NEXT.CHANGELOG.json +1 -0
- package/configure/node_modules/@pie-lib/math-rendering/esm/index.js +690 -0
- package/configure/node_modules/@pie-lib/math-rendering/esm/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/index.js +38 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/mml-to-latex.js +15 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/mml-to-latex.js.map +1 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/mstack/chtml.js +296 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/mstack/chtml.js.map +1 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/mstack/index.js +23 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/mstack/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/mstack/mml.js +109 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/mstack/mml.js.map +1 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/normalization.js +95 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/normalization.js.map +1 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/render-math.js +438 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/render-math.js.map +1 -0
- package/configure/node_modules/@pie-lib/math-rendering/package.json +28 -0
- package/configure/node_modules/@pie-lib/math-rendering/src/__tests__/mml-to-latex.test.js +14 -0
- package/configure/node_modules/@pie-lib/math-rendering/src/__tests__/normalization.test.js +50 -0
- package/configure/node_modules/@pie-lib/math-rendering/src/__tests__/render-math.test.js +155 -0
- package/configure/node_modules/@pie-lib/math-rendering/src/index.js +5 -0
- package/configure/node_modules/@pie-lib/math-rendering/src/mml-to-latex.js +2 -0
- package/configure/node_modules/@pie-lib/math-rendering/src/mstack/__tests__/__snapshots__/chtml.test.js.snap +9 -0
- package/configure/node_modules/@pie-lib/math-rendering/src/mstack/__tests__/chtml.test.js +104 -0
- package/configure/node_modules/@pie-lib/math-rendering/src/mstack/chtml.js +220 -0
- package/configure/node_modules/@pie-lib/math-rendering/src/mstack/index.js +13 -0
- package/configure/node_modules/@pie-lib/math-rendering/src/mstack/mml.js +24 -0
- package/configure/node_modules/@pie-lib/math-rendering/src/normalization.js +69 -0
- package/configure/node_modules/@pie-lib/math-rendering/src/render-math.js +387 -0
- package/configure/node_modules/@pie-lib/render-ui/CHANGELOG.json +1 -0
- package/configure/node_modules/@pie-lib/render-ui/CHANGELOG.md +1026 -0
- package/configure/node_modules/@pie-lib/render-ui/NEXT.CHANGELOG.json +1 -0
- package/configure/node_modules/@pie-lib/render-ui/esm/index.js +1616 -0
- package/configure/node_modules/@pie-lib/render-ui/esm/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/append-css-rules.js +88 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/append-css-rules.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/assets/enableAudioAutoplayImage.js +9 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/assets/enableAudioAutoplayImage.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/collapsible/index.js +135 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/collapsible/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/color.js +344 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/color.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/feedback.js +150 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/feedback.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/has-media.js +27 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/has-media.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/has-text.js +28 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/has-text.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/html-and-math.js +74 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/html-and-math.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/index.js +136 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/input-container.js +60 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/input-container.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/preview-layout.js +145 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/preview-layout.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/preview-prompt.js +321 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/preview-prompt.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/purpose.js +28 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/purpose.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/readable.js +28 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/readable.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/response-indicators.js +151 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/response-indicators.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/ui-layout.js +122 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/ui-layout.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/withUndoReset.js +181 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/withUndoReset.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/package.json +40 -0
- package/configure/node_modules/@pie-lib/render-ui/src/__tests__/__snapshots__/html-and-math.test.js.snap +11 -0
- package/configure/node_modules/@pie-lib/render-ui/src/__tests__/__snapshots__/preview-prompt.test.jsx.snap +37 -0
- package/configure/node_modules/@pie-lib/render-ui/src/__tests__/__snapshots__/purpose.test.jsx.snap +42 -0
- package/configure/node_modules/@pie-lib/render-ui/src/__tests__/__snapshots__/readable.test.jsx.snap +64 -0
- package/configure/node_modules/@pie-lib/render-ui/src/__tests__/__snapshots__/response-indicators.test.jsx.snap +27 -0
- package/configure/node_modules/@pie-lib/render-ui/src/__tests__/color.test.js +12 -0
- package/configure/node_modules/@pie-lib/render-ui/src/__tests__/has-media.test.js +20 -0
- package/configure/node_modules/@pie-lib/render-ui/src/__tests__/has-text.test.js +21 -0
- package/configure/node_modules/@pie-lib/render-ui/src/__tests__/html-and-math.test.js +24 -0
- package/configure/node_modules/@pie-lib/render-ui/src/__tests__/preview-prompt.test.jsx +56 -0
- package/configure/node_modules/@pie-lib/render-ui/src/__tests__/purpose.test.jsx +47 -0
- package/configure/node_modules/@pie-lib/render-ui/src/__tests__/readable.test.jsx +64 -0
- package/configure/node_modules/@pie-lib/render-ui/src/__tests__/response-indicators.test.jsx +16 -0
- package/configure/node_modules/@pie-lib/render-ui/src/__tests__/ui-layout.test.jsx +34 -0
- package/configure/node_modules/@pie-lib/render-ui/src/__tests__/withUndoReset.test.jsx +254 -0
- package/configure/node_modules/@pie-lib/render-ui/src/append-css-rules.js +51 -0
- package/configure/node_modules/@pie-lib/render-ui/src/assets/enableAudioAutoplayImage.js +1 -0
- package/configure/node_modules/@pie-lib/render-ui/src/collapsible/__tests__/__snapshots__/index.test.jsx.snap +18 -0
- package/configure/node_modules/@pie-lib/render-ui/src/collapsible/__tests__/index.test.jsx +13 -0
- package/configure/node_modules/@pie-lib/render-ui/src/collapsible/index.jsx +64 -0
- package/configure/node_modules/@pie-lib/render-ui/src/color.js +121 -0
- package/configure/node_modules/@pie-lib/render-ui/src/feedback.jsx +99 -0
- package/configure/node_modules/@pie-lib/render-ui/src/has-media.js +16 -0
- package/configure/node_modules/@pie-lib/render-ui/src/has-text.js +18 -0
- package/configure/node_modules/@pie-lib/render-ui/src/html-and-math.js +21 -0
- package/configure/node_modules/@pie-lib/render-ui/src/index.js +35 -0
- package/configure/node_modules/@pie-lib/render-ui/src/input-container.jsx +41 -0
- package/configure/node_modules/@pie-lib/render-ui/src/preview-layout.jsx +95 -0
- package/configure/node_modules/@pie-lib/render-ui/src/preview-prompt.jsx +254 -0
- package/configure/node_modules/@pie-lib/render-ui/src/purpose.jsx +17 -0
- package/configure/node_modules/@pie-lib/render-ui/src/readable.jsx +19 -0
- package/configure/node_modules/@pie-lib/render-ui/src/response-indicators.jsx +89 -0
- package/configure/node_modules/@pie-lib/render-ui/src/ui-layout.jsx +66 -0
- package/configure/node_modules/@pie-lib/render-ui/src/withUndoReset.jsx +116 -0
- package/configure/node_modules/@pie-lib/test-utils/CHANGELOG.json +1 -0
- package/configure/node_modules/@pie-lib/test-utils/CHANGELOG.md +410 -0
- package/configure/node_modules/@pie-lib/test-utils/NEXT.CHANGELOG.json +1 -0
- package/configure/node_modules/@pie-lib/test-utils/esm/index.js +39 -0
- package/configure/node_modules/@pie-lib/test-utils/esm/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/test-utils/lib/index.js +40 -0
- package/configure/node_modules/@pie-lib/test-utils/lib/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/test-utils/package.json +25 -0
- package/configure/node_modules/@pie-lib/test-utils/src/__tests__/index.test.js +45 -0
- package/configure/node_modules/@pie-lib/test-utils/src/index.js +18 -0
- package/configure/node_modules/@pie-lib/translator/CHANGELOG.json +1 -0
- package/configure/node_modules/@pie-lib/translator/CHANGELOG.md +282 -0
- package/configure/node_modules/@pie-lib/translator/NEXT.CHANGELOG.json +1 -0
- package/configure/node_modules/@pie-lib/translator/esm/index.js +257 -0
- package/configure/node_modules/@pie-lib/translator/esm/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/translator/lib/en.js +102 -0
- package/configure/node_modules/@pie-lib/translator/lib/en.js.map +1 -0
- package/configure/node_modules/@pie-lib/translator/lib/es.js +102 -0
- package/configure/node_modules/@pie-lib/translator/lib/es.js.map +1 -0
- package/configure/node_modules/@pie-lib/translator/lib/index.js +69 -0
- package/configure/node_modules/@pie-lib/translator/lib/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/translator/package.json +25 -0
- package/configure/node_modules/@pie-lib/translator/src/en.js +99 -0
- package/configure/node_modules/@pie-lib/translator/src/es.js +99 -0
- package/configure/node_modules/@pie-lib/translator/src/index.js +43 -0
- package/configure/package.json +3 -3
- package/controller/CHANGELOG.md +8 -0
- package/controller/package.json +3 -3
- package/esm/configure.js +40550 -0
- package/esm/configure.js.map +1 -0
- package/esm/controller.js +3358 -0
- package/esm/controller.js.map +1 -0
- package/esm/element.js +2203 -0
- package/esm/element.js.map +1 -0
- package/esm/package.json +4 -0
- package/esm/print.js +4090 -0
- package/esm/print.js.map +1 -0
- package/module/controller.js +4973 -2252
- package/module/element.js +1 -1
- package/module/index.html +1 -1
- package/module/manifest.json +1 -1
- package/module/print.html +1 -1
- package/module/print.js +1 -1
- package/package.json +24 -6
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.wrapMath = exports.unWrapMath = exports.BracketTypes = void 0;
|
|
9
|
+
|
|
10
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
|
+
|
|
12
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
+
|
|
14
|
+
var _PAIRS;
|
|
15
|
+
|
|
16
|
+
var BracketTypes = {};
|
|
17
|
+
exports.BracketTypes = BracketTypes;
|
|
18
|
+
BracketTypes.ROUND_BRACKETS = 'round_brackets';
|
|
19
|
+
BracketTypes.SQUARE_BRACKETS = 'square_brackets';
|
|
20
|
+
BracketTypes.DOLLAR = 'dollar';
|
|
21
|
+
BracketTypes.DOUBLE_DOLLAR = 'double_dollar';
|
|
22
|
+
var PAIRS = (_PAIRS = {}, (0, _defineProperty2["default"])(_PAIRS, BracketTypes.ROUND_BRACKETS, ['\\(', '\\)']), (0, _defineProperty2["default"])(_PAIRS, BracketTypes.SQUARE_BRACKETS, ['\\[', '\\]']), (0, _defineProperty2["default"])(_PAIRS, BracketTypes.DOLLAR, ['$', '$']), (0, _defineProperty2["default"])(_PAIRS, BracketTypes.DOUBLE_DOLLAR, ['$$', '$$']), _PAIRS);
|
|
23
|
+
|
|
24
|
+
var wrapMath = function wrapMath(content, wrapType) {
|
|
25
|
+
if (wrapType === BracketTypes.SQUARE_BRACKETS) {
|
|
26
|
+
console.warn('\\[...\\] is not supported yet'); // eslint-disable-line
|
|
27
|
+
|
|
28
|
+
wrapType = BracketTypes.ROUND_BRACKETS;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (wrapType === BracketTypes.DOUBLE_DOLLAR) {
|
|
32
|
+
console.warn('$$...$$ is not supported yet'); // eslint-disable-line
|
|
33
|
+
|
|
34
|
+
wrapType = BracketTypes.DOLLAR;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
var _ref = PAIRS[wrapType] || PAIRS[BracketTypes.ROUND_BRACKETS],
|
|
38
|
+
_ref2 = (0, _slicedToArray2["default"])(_ref, 2),
|
|
39
|
+
start = _ref2[0],
|
|
40
|
+
end = _ref2[1];
|
|
41
|
+
|
|
42
|
+
return "".concat(start).concat(content).concat(end);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
exports.wrapMath = wrapMath;
|
|
46
|
+
|
|
47
|
+
var unWrapMath = function unWrapMath(content) {
|
|
48
|
+
var displayStyleIndex = content.indexOf('\\displaystyle');
|
|
49
|
+
|
|
50
|
+
if (displayStyleIndex !== -1) {
|
|
51
|
+
console.warn('\\displaystyle is not supported - removing'); // eslint-disable-line
|
|
52
|
+
|
|
53
|
+
content = content.replace('\\displaystyle', '').trim();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (content.startsWith('$$') && content.endsWith('$$')) {
|
|
57
|
+
console.warn('$$ syntax is not yet supported'); // eslint-disable-line
|
|
58
|
+
|
|
59
|
+
return {
|
|
60
|
+
unwrapped: content.substring(2, content.length - 2),
|
|
61
|
+
wrapType: BracketTypes.DOLLAR
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (content.startsWith('$') && content.endsWith('$')) {
|
|
66
|
+
return {
|
|
67
|
+
unwrapped: content.substring(1, content.length - 1),
|
|
68
|
+
wrapType: BracketTypes.DOLLAR
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (content.startsWith('\\[') && content.endsWith('\\]')) {
|
|
73
|
+
console.warn('\\[..\\] syntax is not yet supported'); // eslint-disable-line
|
|
74
|
+
|
|
75
|
+
return {
|
|
76
|
+
unwrapped: content.substring(2, content.length - 2),
|
|
77
|
+
wrapType: BracketTypes.ROUND_BRACKETS
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (content.startsWith('\\(') && content.endsWith('\\)')) {
|
|
82
|
+
return {
|
|
83
|
+
unwrapped: content.substring(2, content.length - 2),
|
|
84
|
+
wrapType: BracketTypes.ROUND_BRACKETS
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return {
|
|
89
|
+
unwrapped: content,
|
|
90
|
+
wrapType: BracketTypes.ROUND_BRACKETS
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
exports.unWrapMath = unWrapMath;
|
|
95
|
+
//# sourceMappingURL=normalization.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/normalization.js"],"names":["BracketTypes","ROUND_BRACKETS","SQUARE_BRACKETS","DOLLAR","DOUBLE_DOLLAR","PAIRS","wrapMath","content","wrapType","console","warn","start","end","unWrapMath","displayStyleIndex","indexOf","replace","trim","startsWith","endsWith","unwrapped","substring","length"],"mappings":";;;;;;;;;;;;;;;AAAO,IAAMA,YAAY,GAAG,EAArB;;AAEPA,YAAY,CAACC,cAAb,GAA8B,gBAA9B;AACAD,YAAY,CAACE,eAAb,GAA+B,iBAA/B;AACAF,YAAY,CAACG,MAAb,GAAsB,QAAtB;AACAH,YAAY,CAACI,aAAb,GAA6B,eAA7B;AAEA,IAAMC,KAAK,0DACRL,YAAY,CAACC,cADL,EACsB,CAAC,KAAD,EAAQ,KAAR,CADtB,4CAERD,YAAY,CAACE,eAFL,EAEuB,CAAC,KAAD,EAAQ,KAAR,CAFvB,4CAGRF,YAAY,CAACG,MAHL,EAGc,CAAC,GAAD,EAAM,GAAN,CAHd,4CAIRH,YAAY,CAACI,aAJL,EAIqB,CAAC,IAAD,EAAO,IAAP,CAJrB,UAAX;;AAOO,IAAME,QAAQ,GAAG,SAAXA,QAAW,CAACC,OAAD,EAAUC,QAAV,EAAuB;AAC7C,MAAIA,QAAQ,KAAKR,YAAY,CAACE,eAA9B,EAA+C;AAC7CO,IAAAA,OAAO,CAACC,IAAR,CAAa,gCAAb,EAD6C,CACG;;AAChDF,IAAAA,QAAQ,GAAGR,YAAY,CAACC,cAAxB;AACD;;AACD,MAAIO,QAAQ,KAAKR,YAAY,CAACI,aAA9B,EAA6C;AAC3CK,IAAAA,OAAO,CAACC,IAAR,CAAa,8BAAb,EAD2C,CACG;;AAC9CF,IAAAA,QAAQ,GAAGR,YAAY,CAACG,MAAxB;AACD;;AAED,aAAqBE,KAAK,CAACG,QAAD,CAAL,IAAmBH,KAAK,CAACL,YAAY,CAACC,cAAd,CAA7C;AAAA;AAAA,MAAOU,KAAP;AAAA,MAAcC,GAAd;;AACA,mBAAUD,KAAV,SAAkBJ,OAAlB,SAA4BK,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tC,CADN;AAELd,MAAAA,QAAQ,EAAER,YAAY,CAACC;AAFlB,KAAP;AAID;;AAED,MAAIM,OAAO,CAACW,UAAR,CAAmB,KAAnB,KAA6BX,OAAO,CAACY,QAAR,CAAiB,KAAjB,CAAjC,EAA0D;AACxD,WAAO;AACLC,MAAAA,SAAS,EAAEb,OAAO,CAACc,SAAR,CAAkB,CAAlB,EAAqBd,OAAO,CAACe,MAAR,GAAiB,CAAtC,CADN;AAELd,MAAAA,QAAQ,EAAER,YAAY,CAACC;AAFlB,KAAP;AAID;;AAED,SAAO;AACLmB,IAAAA,SAAS,EAAEb,OADN;AAELC,IAAAA,QAAQ,EAAER,YAAY,CAACC;AAFlB,GAAP;AAID,CAxCM","sourcesContent":["export const BracketTypes = {};\n\nBracketTypes.ROUND_BRACKETS = 'round_brackets';\nBracketTypes.SQUARE_BRACKETS = 'square_brackets';\nBracketTypes.DOLLAR = 'dollar';\nBracketTypes.DOUBLE_DOLLAR = 'double_dollar';\n\nconst PAIRS = {\n [BracketTypes.ROUND_BRACKETS]: ['\\\\(', '\\\\)'],\n [BracketTypes.SQUARE_BRACKETS]: ['\\\\[', '\\\\]'],\n [BracketTypes.DOLLAR]: ['$', '$'],\n [BracketTypes.DOUBLE_DOLLAR]: ['$$', '$$'],\n};\n\nexport const wrapMath = (content, wrapType) => {\n if (wrapType === BracketTypes.SQUARE_BRACKETS) {\n console.warn('\\\\[...\\\\] is not supported yet'); // eslint-disable-line\n wrapType = BracketTypes.ROUND_BRACKETS;\n }\n if (wrapType === BracketTypes.DOUBLE_DOLLAR) {\n console.warn('$$...$$ is not supported yet'); // eslint-disable-line\n wrapType = BracketTypes.DOLLAR;\n }\n\n const [start, end] = PAIRS[wrapType] || PAIRS[BracketTypes.ROUND_BRACKETS];\n return `${start}${content}${end}`;\n};\n\nexport const unWrapMath = (content) => {\n const displayStyleIndex = content.indexOf('\\\\displaystyle');\n if (displayStyleIndex !== -1) {\n console.warn('\\\\displaystyle is not supported - removing'); // eslint-disable-line\n content = content.replace('\\\\displaystyle', '').trim();\n }\n\n if (content.startsWith('$$') && content.endsWith('$$')) {\n console.warn('$$ syntax is not yet supported'); // eslint-disable-line\n return {\n unwrapped: content.substring(2, content.length - 2),\n wrapType: BracketTypes.DOLLAR,\n };\n }\n if (content.startsWith('$') && content.endsWith('$')) {\n return {\n unwrapped: content.substring(1, content.length - 1),\n wrapType: BracketTypes.DOLLAR,\n };\n }\n\n if (content.startsWith('\\\\[') && content.endsWith('\\\\]')) {\n console.warn('\\\\[..\\\\] syntax is not yet supported'); // eslint-disable-line\n return {\n unwrapped: content.substring(2, content.length - 2),\n wrapType: BracketTypes.ROUND_BRACKETS,\n };\n }\n\n if (content.startsWith('\\\\(') && content.endsWith('\\\\)')) {\n return {\n unwrapped: content.substring(2, content.length - 2),\n wrapType: BracketTypes.ROUND_BRACKETS,\n };\n }\n\n return {\n unwrapped: content,\n wrapType: BracketTypes.ROUND_BRACKETS,\n };\n};\n"],"file":"normalization.js"}
|
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.fixMathElements = exports.fixMathElement = exports["default"] = void 0;
|
|
9
|
+
|
|
10
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
|
+
|
|
12
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
13
|
+
|
|
14
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
15
|
+
|
|
16
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
17
|
+
|
|
18
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
19
|
+
|
|
20
|
+
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
21
|
+
|
|
22
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
23
|
+
|
|
24
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
25
|
+
|
|
26
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
27
|
+
|
|
28
|
+
var _mathjax = require("mathjax-full/js/mathjax");
|
|
29
|
+
|
|
30
|
+
var _global = require("mathjax-full/js/components/global");
|
|
31
|
+
|
|
32
|
+
var _assistiveMml = require("mathjax-full/js/a11y/assistive-mml");
|
|
33
|
+
|
|
34
|
+
var _semanticEnrich = require("mathjax-full/js/a11y/semantic-enrich");
|
|
35
|
+
|
|
36
|
+
var _MenuHandler = require("mathjax-full/js/ui/menu/MenuHandler");
|
|
37
|
+
|
|
38
|
+
var _FindMathML2 = require("mathjax-full/js/input/mathml/FindMathML");
|
|
39
|
+
|
|
40
|
+
var _mathml = require("mathjax-full/js/input/mathml");
|
|
41
|
+
|
|
42
|
+
var _tex = require("mathjax-full/js/input/tex");
|
|
43
|
+
|
|
44
|
+
var _chtml = require("mathjax-full/js/output/chtml");
|
|
45
|
+
|
|
46
|
+
var _html = require("mathjax-full/js/handlers/html");
|
|
47
|
+
|
|
48
|
+
var _browserAdaptor = require("mathjax-full/js/adaptors/browserAdaptor");
|
|
49
|
+
|
|
50
|
+
var _AllPackages = require("mathjax-full/js/input/tex/AllPackages");
|
|
51
|
+
|
|
52
|
+
var _system = require("speech-rule-engine/js/common/system");
|
|
53
|
+
|
|
54
|
+
var _mstack = require("./mstack");
|
|
55
|
+
|
|
56
|
+
var _debug = _interopRequireDefault(require("debug"));
|
|
57
|
+
|
|
58
|
+
var _normalization = require("./normalization");
|
|
59
|
+
|
|
60
|
+
var _MmlFactory = require("mathjax-full/js/core/MmlTree/MmlFactory");
|
|
61
|
+
|
|
62
|
+
var _SerializedMmlVisitor = require("mathjax-full/js/core/MmlTree/SerializedMmlVisitor");
|
|
63
|
+
|
|
64
|
+
var _WrapperFactory = require("mathjax-full/js/output/chtml/WrapperFactory");
|
|
65
|
+
|
|
66
|
+
var _mspace = require("mathjax-full/js/output/chtml/Wrappers/mspace");
|
|
67
|
+
|
|
68
|
+
var _HTMLDomStrings = require("mathjax-full/js/handlers/html/HTMLDomStrings");
|
|
69
|
+
|
|
70
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
71
|
+
|
|
72
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
73
|
+
|
|
74
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
75
|
+
|
|
76
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
77
|
+
|
|
78
|
+
if (typeof window !== 'undefined') {
|
|
79
|
+
(0, _html.RegisterHTMLHandler)((0, _browserAdaptor.browserAdaptor)());
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
var sreReady = false;
|
|
83
|
+
(0, _system.engineReady)().then(function () {
|
|
84
|
+
sreReady = true;
|
|
85
|
+
}); // import pkg from '../../package.json';
|
|
86
|
+
|
|
87
|
+
var visitor = new _SerializedMmlVisitor.SerializedMmlVisitor();
|
|
88
|
+
|
|
89
|
+
var toMMl = function toMMl(node) {
|
|
90
|
+
return visitor.visitTree(node);
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
var log = (0, _debug["default"])('pie-lib:math-rendering');
|
|
94
|
+
var NEWLINE_BLOCK_REGEX = /\\embed\{newLine\}\[\]/g;
|
|
95
|
+
var NEWLINE_LATEX = '\\newline ';
|
|
96
|
+
|
|
97
|
+
var getGlobal = function getGlobal() {
|
|
98
|
+
// TODO does it make sense to use version?
|
|
99
|
+
// const key = `${pkg.name}@${pkg.version.split('.')[0]}`;
|
|
100
|
+
// It looks like Ed made this change when he switched from mathjax3 to mathjax-full
|
|
101
|
+
// I think it was supposed to make sure version 1 (using mathjax3) is not used
|
|
102
|
+
// in combination with version 2 (using mathjax-full)
|
|
103
|
+
// TODO higher level wrappers use this instance of math-rendering, and if 2 different instances are used, math rendering is not working
|
|
104
|
+
// so I will hardcode this for now until a better solution is found
|
|
105
|
+
var key = '@pie-lib/math-rendering@2';
|
|
106
|
+
|
|
107
|
+
if (typeof window !== 'undefined') {
|
|
108
|
+
if (!window[key]) {
|
|
109
|
+
window[key] = {};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return window[key];
|
|
113
|
+
} else {
|
|
114
|
+
return {};
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
/** Add temporary support for a global singleDollar override
|
|
118
|
+
* <code>
|
|
119
|
+
* // This will enable single dollar rendering
|
|
120
|
+
* window.pie = window.pie || {};
|
|
121
|
+
* window.pie.mathRendering = {useSingleDollar: true };
|
|
122
|
+
* </code>
|
|
123
|
+
*/
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
var defaultOpts = function defaultOpts() {
|
|
127
|
+
return getGlobal().opts || {};
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
var fixMathElement = function fixMathElement(element) {
|
|
131
|
+
if (element.dataset.mathHandled) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
var property = 'innerText';
|
|
136
|
+
|
|
137
|
+
if (element.textContent) {
|
|
138
|
+
property = 'textContent';
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (element[property]) {
|
|
142
|
+
element[property] = (0, _normalization.wrapMath)((0, _normalization.unWrapMath)(element[property]).unwrapped); // because mathquill doesn't understand line breaks, sometimes we end up with custom elements on prompts/rationale/etc.
|
|
143
|
+
// we need to replace the custom embedded elements with valid latex that Mathjax can understand
|
|
144
|
+
|
|
145
|
+
element[property] = element[property].replace(NEWLINE_BLOCK_REGEX, NEWLINE_LATEX);
|
|
146
|
+
element.dataset.mathHandled = true;
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
exports.fixMathElement = fixMathElement;
|
|
151
|
+
|
|
152
|
+
var fixMathElements = function fixMathElements() {
|
|
153
|
+
var el = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : document;
|
|
154
|
+
var mathElements = el.querySelectorAll('[data-latex]');
|
|
155
|
+
mathElements.forEach(function (item) {
|
|
156
|
+
return fixMathElement(item);
|
|
157
|
+
});
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
exports.fixMathElements = fixMathElements;
|
|
161
|
+
|
|
162
|
+
var adjustMathMLStyle = function adjustMathMLStyle() {
|
|
163
|
+
var el = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : document;
|
|
164
|
+
var nodes = el.querySelectorAll('math');
|
|
165
|
+
nodes.forEach(function (node) {
|
|
166
|
+
return node.setAttribute('displaystyle', 'true');
|
|
167
|
+
});
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
var myFindMathML = /*#__PURE__*/function (_FindMathML) {
|
|
171
|
+
(0, _inherits2["default"])(myFindMathML, _FindMathML);
|
|
172
|
+
|
|
173
|
+
var _super = _createSuper(myFindMathML);
|
|
174
|
+
|
|
175
|
+
function myFindMathML() {
|
|
176
|
+
(0, _classCallCheck2["default"])(this, myFindMathML);
|
|
177
|
+
return _super.apply(this, arguments);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
(0, _createClass2["default"])(myFindMathML, [{
|
|
181
|
+
key: "processMath",
|
|
182
|
+
value: function processMath(set) {
|
|
183
|
+
var adaptor = this.adaptor;
|
|
184
|
+
|
|
185
|
+
for (var _i = 0, _Array$from = Array.from(set); _i < _Array$from.length; _i++) {
|
|
186
|
+
var mml = _Array$from[_i];
|
|
187
|
+
|
|
188
|
+
if (adaptor.kind(adaptor.parent(mml)) === 'mjx-assistive-mml') {
|
|
189
|
+
set["delete"](mml);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
return (0, _get2["default"])((0, _getPrototypeOf2["default"])(myFindMathML.prototype), "processMath", this).call(this, set);
|
|
194
|
+
}
|
|
195
|
+
}]);
|
|
196
|
+
return myFindMathML;
|
|
197
|
+
}(_FindMathML2.FindMathML);
|
|
198
|
+
|
|
199
|
+
var createMathMLInstance = function createMathMLInstance(opts) {
|
|
200
|
+
var docProvided = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : document;
|
|
201
|
+
opts = opts || defaultOpts();
|
|
202
|
+
|
|
203
|
+
if (opts.useSingleDollar) {
|
|
204
|
+
// eslint-disable-next-line
|
|
205
|
+
console.warn('[math-rendering] using $ is not advisable, please use $$..$$ or \\(...\\)');
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
var packages = _AllPackages.AllPackages.filter(function (name) {
|
|
209
|
+
return name !== 'bussproofs';
|
|
210
|
+
}); // Bussproofs needs an output jax
|
|
211
|
+
// The autoload extension predefines all the macros from the extensions that haven't been loaded already
|
|
212
|
+
// so that they automatically load the needed extension when they are first used
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
packages.push('autoload');
|
|
216
|
+
var macros = {
|
|
217
|
+
parallelogram: "\\lower.2em{\\Huge\\unicode{x25B1}}",
|
|
218
|
+
overarc: '\\overparen',
|
|
219
|
+
napprox: '\\not\\approx',
|
|
220
|
+
longdiv: '\\enclose{longdiv}'
|
|
221
|
+
};
|
|
222
|
+
var texConfig = opts.useSingleDollar ? {
|
|
223
|
+
packages: packages,
|
|
224
|
+
macros: macros,
|
|
225
|
+
inlineMath: [['$', '$'], ['\\(', '\\)']],
|
|
226
|
+
processEscapes: true
|
|
227
|
+
} : {
|
|
228
|
+
packages: packages,
|
|
229
|
+
macros: macros
|
|
230
|
+
};
|
|
231
|
+
var mmlConfig = {
|
|
232
|
+
parseError: function parseError(node) {
|
|
233
|
+
// function to process parsing errors
|
|
234
|
+
// eslint-disable-next-line no-console
|
|
235
|
+
console.log('error:', node);
|
|
236
|
+
this.error(this.adaptor.textContent(node).replace(/\n.*/g, ''));
|
|
237
|
+
},
|
|
238
|
+
FindMathML: new myFindMathML()
|
|
239
|
+
};
|
|
240
|
+
var cachedMathjax;
|
|
241
|
+
|
|
242
|
+
if (_global.MathJax && _global.MathJax.version !== _mathjax.mathjax.version) {
|
|
243
|
+
// handling other MathJax version on the page
|
|
244
|
+
// replacing it temporarily with the version we have
|
|
245
|
+
window.MathJax._ = window.MathJax._ || {};
|
|
246
|
+
window.MathJax.config = window.MathJax.config || {};
|
|
247
|
+
cachedMathjax = window.MathJax;
|
|
248
|
+
Object.assign(_global.MathJax, _mathjax.mathjax);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
var fontURL = "https://unpkg.com/mathjax-full@".concat(_mathjax.mathjax.version, "/ts/output/chtml/fonts/tex-woff-v2");
|
|
252
|
+
var htmlConfig = {
|
|
253
|
+
fontURL: fontURL,
|
|
254
|
+
wrapperFactory: new _WrapperFactory.CHTMLWrapperFactory(_objectSpread(_objectSpread({}, _WrapperFactory.CHTMLWrapperFactory.defaultNodes), _mstack.chtmlNodes))
|
|
255
|
+
};
|
|
256
|
+
var mml = new _mathml.MathML(mmlConfig);
|
|
257
|
+
var customMmlFactory = new _MmlFactory.MmlFactory(_objectSpread(_objectSpread({}, _MmlFactory.MmlFactory.defaultNodes), _mstack.mmlNodes));
|
|
258
|
+
var classFactory = (0, _semanticEnrich.EnrichHandler)((0, _MenuHandler.MenuHandler)((0, _assistiveMml.AssistiveMmlHandler)(_mathjax.mathjax.handlers.handlesDocument(docProvided))), mml);
|
|
259
|
+
var html = classFactory.create(docProvided, {
|
|
260
|
+
compileError: function compileError(mj, math, err) {
|
|
261
|
+
// eslint-disable-next-line no-console
|
|
262
|
+
console.log('bad math?:', math); // eslint-disable-next-line no-console
|
|
263
|
+
|
|
264
|
+
console.error(err);
|
|
265
|
+
},
|
|
266
|
+
typesetError: function typesetError(doc, math, err) {
|
|
267
|
+
// eslint-disable-next-line no-console
|
|
268
|
+
console.log('typeset error'); // eslint-disable-next-line no-console
|
|
269
|
+
|
|
270
|
+
console.error(err);
|
|
271
|
+
doc.typesetError(math, err);
|
|
272
|
+
},
|
|
273
|
+
sre: {
|
|
274
|
+
speech: 'deep'
|
|
275
|
+
},
|
|
276
|
+
enrichSpeech: 'deep',
|
|
277
|
+
InputJax: [new _tex.TeX(texConfig), mml],
|
|
278
|
+
OutputJax: new _chtml.CHTML(htmlConfig),
|
|
279
|
+
DomStrings: new _HTMLDomStrings.HTMLDomStrings({
|
|
280
|
+
skipHtmlTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code', 'annotation', 'annotation-xml', 'mjx-assistive-mml', 'mjx-container']
|
|
281
|
+
})
|
|
282
|
+
}); // Note: we must set this *after* mathjax.document (no idea why)
|
|
283
|
+
|
|
284
|
+
mml.setMmlFactory(customMmlFactory);
|
|
285
|
+
|
|
286
|
+
if (cachedMathjax) {
|
|
287
|
+
// if we have a cached version, we replace it here
|
|
288
|
+
window.MathJax = cachedMathjax;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
return html;
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
var enrichSpeechInitialized = false;
|
|
295
|
+
|
|
296
|
+
var bootstrap = function bootstrap(opts) {
|
|
297
|
+
if (typeof window === 'undefined') {
|
|
298
|
+
return {
|
|
299
|
+
Typeset: function Typeset() {
|
|
300
|
+
return {};
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
var html = createMathMLInstance(opts);
|
|
306
|
+
return {
|
|
307
|
+
version: _mathjax.mathjax.version,
|
|
308
|
+
html: html,
|
|
309
|
+
Typeset: function Typeset() {
|
|
310
|
+
var _this = this;
|
|
311
|
+
|
|
312
|
+
for (var _len = arguments.length, elements = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
313
|
+
elements[_key] = arguments[_key];
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
var attemptRender = function attemptRender() {
|
|
317
|
+
var _updatedDocument$math, _updatedDocument$math2;
|
|
318
|
+
|
|
319
|
+
var temporary = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
320
|
+
|
|
321
|
+
var updatedDocument = _this.html.findMath(elements.length ? {
|
|
322
|
+
elements: elements
|
|
323
|
+
} : {}).compile();
|
|
324
|
+
|
|
325
|
+
if (!temporary && sreReady) {
|
|
326
|
+
updatedDocument = updatedDocument.enrich();
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
updatedDocument = updatedDocument.getMetrics().typeset().assistiveMml().attachSpeech().addMenu().updateDocument();
|
|
330
|
+
|
|
331
|
+
if (!enrichSpeechInitialized && (0, _typeof2["default"])((_updatedDocument$math = updatedDocument.math.list) === null || _updatedDocument$math === void 0 ? void 0 : (_updatedDocument$math2 = _updatedDocument$math.next) === null || _updatedDocument$math2 === void 0 ? void 0 : _updatedDocument$math2.data) === 'object') {
|
|
332
|
+
enrichSpeechInitialized = true;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
try {
|
|
336
|
+
var list = updatedDocument.math.list;
|
|
337
|
+
|
|
338
|
+
if (list) {
|
|
339
|
+
for (var item = list.next; (0, _typeof2["default"])(item.data) !== 'symbol'; item = item.next) {
|
|
340
|
+
var mathMl = toMMl(item.data.root);
|
|
341
|
+
var parsedMathMl = mathMl.replaceAll('\n', '');
|
|
342
|
+
item.data.typesetRoot.setAttribute('data-mathml', parsedMathMl);
|
|
343
|
+
item.data.typesetRoot.setAttribute('tabindex', '-1');
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
} catch (e) {
|
|
347
|
+
// eslint-disable-next-line no-console
|
|
348
|
+
console.error(e.toString());
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
updatedDocument.clear();
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
if (!enrichSpeechInitialized) {
|
|
355
|
+
attemptRender(true);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
_mathjax.mathjax.handleRetriesFor(function () {
|
|
359
|
+
attemptRender();
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
};
|
|
363
|
+
};
|
|
364
|
+
|
|
365
|
+
var renderMath = function renderMath(el, renderOpts) {
|
|
366
|
+
var _getGlobal$instance, _getGlobal$instance2;
|
|
367
|
+
|
|
368
|
+
if (window && window.MathJax && window.MathJax.customKey && window.MathJax.customKey == '@pie-lib/math-rendering-accessible@1') {
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
var isString = typeof el === 'string';
|
|
373
|
+
var executeOn = document.body;
|
|
374
|
+
|
|
375
|
+
if (isString) {
|
|
376
|
+
var div = document.createElement('div');
|
|
377
|
+
div.innerHTML = el;
|
|
378
|
+
executeOn = div;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
fixMathElements(executeOn);
|
|
382
|
+
adjustMathMLStyle(executeOn);
|
|
383
|
+
|
|
384
|
+
if (isString) {
|
|
385
|
+
var html = createMathMLInstance(undefined, executeOn);
|
|
386
|
+
var updatedDocument = html.findMath().compile().getMetrics().typeset().updateDocument();
|
|
387
|
+
var list = updatedDocument.math.list;
|
|
388
|
+
var item = list.next;
|
|
389
|
+
|
|
390
|
+
if (!item) {
|
|
391
|
+
return '';
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
var mathMl = toMMl(item.data.root);
|
|
395
|
+
var parsedMathMl = mathMl.replaceAll('\n', '');
|
|
396
|
+
return parsedMathMl;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
if (!getGlobal().instance) {
|
|
400
|
+
getGlobal().instance = bootstrap(renderOpts);
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
if (!el) {
|
|
404
|
+
log('el is undefined');
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
if (el instanceof Element && (_getGlobal$instance = getGlobal().instance) !== null && _getGlobal$instance !== void 0 && _getGlobal$instance.Typeset) {
|
|
409
|
+
getGlobal().instance.Typeset(el);
|
|
410
|
+
} else if (el.length && (_getGlobal$instance2 = getGlobal().instance) !== null && _getGlobal$instance2 !== void 0 && _getGlobal$instance2.Typeset) {
|
|
411
|
+
var _getGlobal$instance3;
|
|
412
|
+
|
|
413
|
+
var arr = Array.from(el);
|
|
414
|
+
|
|
415
|
+
(_getGlobal$instance3 = getGlobal().instance).Typeset.apply(_getGlobal$instance3, (0, _toConsumableArray2["default"])(arr));
|
|
416
|
+
}
|
|
417
|
+
};
|
|
418
|
+
/**
|
|
419
|
+
* This style is added to overried default styling of mjx-mspace Mathjax tag
|
|
420
|
+
* In mathjax src code \newline latex gets parsed to <mjx-mspace></mjx-mspace>,
|
|
421
|
+
* but has the default style
|
|
422
|
+
* 'mjx-mspace': {
|
|
423
|
+
"display": 'in-line',
|
|
424
|
+
"text-align": 'left'
|
|
425
|
+
} which prevents it from showing as a newline value
|
|
426
|
+
*/
|
|
427
|
+
|
|
428
|
+
|
|
429
|
+
_mspace.CHTMLmspace.styles = {
|
|
430
|
+
'mjx-mspace': {
|
|
431
|
+
display: 'block',
|
|
432
|
+
'text-align': 'center',
|
|
433
|
+
height: '5px'
|
|
434
|
+
}
|
|
435
|
+
};
|
|
436
|
+
var _default = renderMath;
|
|
437
|
+
exports["default"] = _default;
|
|
438
|
+
//# sourceMappingURL=render-math.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/render-math.js"],"names":["window","sreReady","then","visitor","SerializedMmlVisitor","toMMl","node","visitTree","log","NEWLINE_BLOCK_REGEX","NEWLINE_LATEX","getGlobal","key","defaultOpts","opts","fixMathElement","element","dataset","mathHandled","property","textContent","unwrapped","replace","fixMathElements","el","document","mathElements","querySelectorAll","forEach","item","adjustMathMLStyle","nodes","setAttribute","myFindMathML","set","adaptor","Array","from","mml","kind","parent","FindMathML","createMathMLInstance","docProvided","useSingleDollar","console","warn","packages","AllPackages","filter","name","push","macros","parallelogram","overarc","napprox","longdiv","texConfig","inlineMath","processEscapes","mmlConfig","parseError","error","cachedMathjax","globalMathjax","version","mathjax","MathJax","_","config","Object","assign","fontURL","htmlConfig","wrapperFactory","CHTMLWrapperFactory","defaultNodes","chtmlNodes","MathML","customMmlFactory","MmlFactory","mmlNodes","classFactory","handlers","handlesDocument","html","create","compileError","mj","math","err","typesetError","doc","sre","speech","enrichSpeech","InputJax","TeX","OutputJax","CHTML","DomStrings","HTMLDomStrings","skipHtmlTags","setMmlFactory","enrichSpeechInitialized","bootstrap","Typeset","elements","attemptRender","temporary","updatedDocument","findMath","length","compile","enrich","getMetrics","typeset","assistiveMml","attachSpeech","addMenu","updateDocument","list","next","data","mathMl","root","parsedMathMl","replaceAll","typesetRoot","e","toString","clear","handleRetriesFor","renderMath","renderOpts","customKey","isString","executeOn","body","div","createElement","innerHTML","undefined","instance","Element","arr","CHTMLmspace","styles","display","height"],"mappings":";;;;;;;;;;;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wF,MAAH,4BAAarG,SAAS,GAAGoI,QAAzB,iDAAa,qBAAsBrC,OAAvC,EAAgD;AAAA;;AACrD,QAAMuC,GAAG,GAAG7G,KAAK,CAACC,IAAN,CAAWb,EAAX,CAAZ;;AACA,4BAAAb,SAAS,GAAGoI,QAAZ,EAAqBrC,OAArB,iEAAgCuC,GAAhC;AACD;AACF,CA7DD;AA+DA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACAC,oBAAYC,MAAZ,GAAqB;AACnB,gBAAc;AACZC,IAAAA,OAAO,EAAE,OADG;AAEZ,kBAAc,QAFF;AAGZC,IAAAA,MAAM,EAAE;AAHI;AADK,CAArB;eAQehB,U","sourcesContent":["import { mathjax } from 'mathjax-full/js/mathjax';\nimport { MathJax as globalMathjax } from 'mathjax-full/js/components/global';\nimport { AssistiveMmlHandler } from 'mathjax-full/js/a11y/assistive-mml';\nimport { EnrichHandler } from 'mathjax-full/js/a11y/semantic-enrich';\nimport { MenuHandler } from 'mathjax-full/js/ui/menu/MenuHandler';\nimport { FindMathML } from 'mathjax-full/js/input/mathml/FindMathML';\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';\nimport { engineReady } from 'speech-rule-engine/js/common/system';\n\nif (typeof window !== 'undefined') {\n RegisterHTMLHandler(browserAdaptor());\n}\n\nlet sreReady = false;\n\nengineReady().then(() => {\n sreReady = true;\n});\n\n// import 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 { SerializedMmlVisitor } from 'mathjax-full/js/core/MmlTree/SerializedMmlVisitor';\nimport { CHTMLWrapperFactory } from 'mathjax-full/js/output/chtml/WrapperFactory';\nimport { CHTMLmspace } from 'mathjax-full/js/output/chtml/Wrappers/mspace';\nimport { HTMLDomStrings } from 'mathjax-full/js/handlers/html/HTMLDomStrings';\n\nconst visitor = new SerializedMmlVisitor();\nconst toMMl = (node) => visitor.visitTree(node);\n\nconst log = debug('pie-lib:math-rendering');\n\nconst NEWLINE_BLOCK_REGEX = /\\\\embed\\{newLine\\}\\[\\]/g;\nconst NEWLINE_LATEX = '\\\\newline ';\n\nconst 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\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 const key = '@pie-lib/math-rendering@2';\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 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\nclass myFindMathML extends FindMathML {\n processMath(set) {\n const adaptor = this.adaptor;\n for (const mml of Array.from(set)) {\n if (adaptor.kind(adaptor.parent(mml)) === 'mjx-assistive-mml') {\n set.delete(mml);\n }\n }\n return super.processMath(set);\n }\n}\n\nconst createMathMLInstance = (opts, docProvided = document) => {\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 ['$', '$'],\n ['\\\\(', '\\\\)'],\n ],\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 // eslint-disable-next-line no-console\n console.log('error:', node);\n this.error(this.adaptor.textContent(node).replace(/\\n.*/g, ''));\n },\n FindMathML: new myFindMathML(),\n };\n\n let cachedMathjax;\n\n if (globalMathjax && globalMathjax.version !== mathjax.version) {\n // handling other MathJax version on the page\n // replacing it temporarily with the version we have\n window.MathJax._ = window.MathJax._ || {};\n window.MathJax.config = window.MathJax.config || {};\n cachedMathjax = window.MathJax;\n Object.assign(globalMathjax, mathjax);\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 const classFactory = EnrichHandler(\n MenuHandler(AssistiveMmlHandler(mathjax.handlers.handlesDocument(docProvided))),\n mml,\n );\n\n const html = classFactory.create(docProvided, {\n compileError: (mj, math, err) => {\n // eslint-disable-next-line no-console\n console.log('bad math?:', math);\n // eslint-disable-next-line no-console\n console.error(err);\n },\n typesetError: function(doc, math, err) {\n // eslint-disable-next-line no-console\n console.log('typeset error');\n // eslint-disable-next-line no-console\n console.error(err);\n doc.typesetError(math, err);\n },\n\n sre: {\n speech: 'deep',\n },\n enrichSpeech: 'deep',\n\n InputJax: [new TeX(texConfig), mml],\n OutputJax: new CHTML(htmlConfig),\n DomStrings: new HTMLDomStrings({\n skipHtmlTags: [\n 'script',\n 'noscript',\n 'style',\n 'textarea',\n 'pre',\n 'code',\n 'annotation',\n 'annotation-xml',\n 'mjx-assistive-mml',\n 'mjx-container',\n ],\n }),\n });\n\n // Note: we must set this *after* mathjax.document (no idea why)\n mml.setMmlFactory(customMmlFactory);\n\n if (cachedMathjax) {\n // if we have a cached version, we replace it here\n window.MathJax = cachedMathjax;\n }\n\n return html;\n};\n\nlet enrichSpeechInitialized = false;\n\nconst bootstrap = (opts) => {\n if (typeof window === 'undefined') {\n return { Typeset: () => ({}) };\n }\n\n const html = createMathMLInstance(opts);\n\n return {\n version: mathjax.version,\n html: html,\n Typeset: function(...elements) {\n const attemptRender = (temporary = false) => {\n let updatedDocument = this.html.findMath(elements.length ? { elements } : {}).compile();\n\n if (!temporary && sreReady) {\n updatedDocument = updatedDocument.enrich();\n }\n\n updatedDocument = updatedDocument\n .getMetrics()\n .typeset()\n .assistiveMml()\n .attachSpeech()\n .addMenu()\n .updateDocument();\n\n if (!enrichSpeechInitialized && typeof updatedDocument.math.list?.next?.data === 'object') {\n enrichSpeechInitialized = true;\n }\n\n try {\n const list = updatedDocument.math.list;\n\n if (list) {\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 } catch (e) {\n // eslint-disable-next-line no-console\n console.error(e.toString());\n }\n\n updatedDocument.clear();\n };\n\n if (!enrichSpeechInitialized) {\n attemptRender(true);\n }\n\n mathjax.handleRetriesFor(() => {\n attemptRender();\n });\n },\n };\n};\n\nconst renderMath = (el, renderOpts) => {\n if (\n window &&\n window.MathJax &&\n window.MathJax.customKey &&\n window.MathJax.customKey == '@pie-lib/math-rendering-accessible@1'\n ) {\n return;\n }\n\n const isString = typeof el === 'string';\n let executeOn = document.body;\n\n if (isString) {\n const div = document.createElement('div');\n\n div.innerHTML = el;\n executeOn = div;\n }\n\n fixMathElements(executeOn);\n adjustMathMLStyle(executeOn);\n\n if (isString) {\n const html = createMathMLInstance(undefined, executeOn);\n\n const updatedDocument = html\n .findMath()\n .compile()\n .getMetrics()\n .typeset()\n .updateDocument();\n\n const list = updatedDocument.math.list;\n const item = list.next;\n\n if (!item) {\n return '';\n }\n\n const mathMl = toMMl(item.data.root);\n const parsedMathMl = mathMl.replaceAll('\\n', '');\n\n return parsedMathMl;\n }\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 && getGlobal().instance?.Typeset) {\n getGlobal().instance.Typeset(el);\n } else if (el.length && getGlobal().instance?.Typeset) {\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"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pie-lib/math-rendering",
|
|
3
|
+
"version": "3.19.2",
|
|
4
|
+
"description": "math rendering utilities",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"main": "lib/index.js",
|
|
9
|
+
"module": "src/index.js",
|
|
10
|
+
"author": "pie-framework developers",
|
|
11
|
+
"license": "ISC",
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@pie-framework/mathml-to-latex": "1.4.4",
|
|
14
|
+
"debug": "^4.1.1",
|
|
15
|
+
"lodash": "^4.17.11",
|
|
16
|
+
"mathjax-full": "3.2.2",
|
|
17
|
+
"react": "^16.8.1"
|
|
18
|
+
},
|
|
19
|
+
"gitHead": "8a327571bd64249e4c88c0c8e750d16d6213f535",
|
|
20
|
+
"scripts": {},
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"import": "./esm/index.js",
|
|
24
|
+
"require": "./lib/index.js",
|
|
25
|
+
"default": "./esm/index.js"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import mmlToLatex from '../mml-to-latex';
|
|
3
|
+
|
|
4
|
+
describe('mmlToLatex', () => {
|
|
5
|
+
it('should work', () => {
|
|
6
|
+
const mml =
|
|
7
|
+
'<math xmlns="http://www.w3.org/1998/Math/MathML"> <mn>2</mn> <mi>x</mi> <mtext> </mtext> <mo>≤</mo> <mn>4</mn> <mi>y</mi> <mtext> </mtext> <mo>+</mo> <mtext> </mtext> <mn>8</mn> <msqrt> <mi>h</mi> </msqrt></math>';
|
|
8
|
+
// todo revisit this
|
|
9
|
+
// const latex = '2x\\text{ }\\leq4y\\text{ }+\\text{ }8\\sqrt{h}';
|
|
10
|
+
const latex = '2 x \\textrm{ } \\leq 4 y \\textrm{ } + \\textrm{ } 8 \\sqrt{h}';
|
|
11
|
+
|
|
12
|
+
expect(mmlToLatex(mml)).toEqual(latex);
|
|
13
|
+
});
|
|
14
|
+
});
|