jekyll-theme-hydejack 8.3.2 → 9.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +1208 -0
- data/LICENSE.md +9 -3
- data/NOTICE.md +290 -0
- data/README.md +135 -93
- data/_config.yml +73 -0
- data/_includes/base-classes +9 -0
- data/_includes/body/analytics.html +1 -1
- data/_includes/body/comments.html +1 -1
- data/_includes/body/footer.html +3 -3
- data/_includes/body/index.html +17 -16
- data/_includes/body/main.html +3 -13
- data/_includes/body/menu.html +3 -2
- data/_includes/body/nav.html +4 -4
- data/_includes/body/scripts.html +5 -20
- data/_includes/body/sidebar-bg.html +13 -0
- data/_includes/body/sidebar-sticky.html +25 -0
- data/_includes/body/sidebar.html +7 -40
- data/_includes/components/about.html +1 -1
- data/_includes/components/author.html +3 -3
- data/_includes/components/hy-img.html +15 -26
- data/_includes/components/link.html +1 -1
- data/_includes/components/message.html +1 -1
- data/_includes/components/post-list-item.html +3 -5
- data/_includes/components/post.html +14 -11
- data/_includes/components/related-posts.html +14 -4
- data/_includes/components/tag-list.html +5 -1
- data/_includes/head/css/inline +1 -0
- data/_includes/head/index.html +14 -8
- data/_includes/head/links-static.html +27 -0
- data/_includes/head/links.html +1 -34
- data/_includes/head/meta-static.html +18 -0
- data/_includes/head/meta.html +9 -21
- data/_includes/head/page-style.html +1 -3
- data/_includes/head/scripts.html +13 -14
- data/_includes/head/styles-inline.html +19 -0
- data/_includes/head/styles-layout.html +4 -0
- data/_includes/head/styles-no-inline.html +8 -0
- data/_includes/head/styles.html +5 -46
- data/_includes/header.txt +1 -1
- data/_includes/if-non-null +7 -0
- data/_includes/my-body.html +1 -1
- data/_includes/my-scripts.html +1 -1
- data/_includes/scripts/load-js.min.js +1 -1
- data/_includes/scripts/nomodule.js +21 -0
- data/_includes/scripts/nomodule.min.js +1 -0
- data/_includes/smart-url +1 -0
- data/_includes/smart-url.txt +1 -1
- data/_includes/styles/common.scss +18 -0
- data/_includes/styles/inline.scss +16 -38
- data/_includes/styles/page-style.scss +5 -52
- data/_includes/styles/style.scss +22 -43
- data/_includes/styles/variables.scss +62 -0
- data/_includes/templates/animation.html +1 -1
- data/_includes/templates/back.html +3 -3
- data/_includes/templates/error.html +1 -1
- data/_includes/templates/forward.html +6 -0
- data/_includes/templates/index.html +10 -10
- data/_includes/templates/loading.html +1 -1
- data/_includes/templates/permalink.html +2 -2
- data/_layouts/about.html +1 -1
- data/_layouts/base.html +7 -2
- data/_layouts/blog.html +9 -7
- data/_layouts/compress.html +1 -1
- data/_layouts/default.html +4 -4
- data/_layouts/list.html +11 -17
- data/_layouts/page.html +1 -0
- data/_layouts/post.html +5 -3
- data/_sass/_mixins.scss +7 -21
- data/_sass/_spinner.scss +1 -1
- data/_sass/_syntax.scss +142 -130
- data/_sass/_variables.scss +2 -43
- data/_sass/html.scss +42 -0
- data/_sass/hydejack/__inline__/_avatar.scss +10 -10
- data/_sass/hydejack/__inline__/_base.scss +7 -21
- data/_sass/hydejack/__inline__/_content.scss +9 -2
- data/_sass/hydejack/__inline__/_images.scss +1 -3
- data/_sass/hydejack/__inline__/_links.scss +28 -13
- data/_sass/hydejack/__inline__/_menu.scss +42 -13
- data/_sass/hydejack/__inline__/_sidebar.scss +40 -14
- data/_sass/hydejack/__inline__/_social.scss +3 -0
- data/_sass/hydejack/__inline__/_toc.scss +55 -0
- data/_sass/hydejack/__inline__/_utilities.scss +3 -0
- data/_sass/hydejack/__link__/_avatar.scss +0 -4
- data/_sass/hydejack/__link__/_base.scss +1 -2
- data/_sass/hydejack/__link__/_break-layout.scss +17 -8
- data/_sass/hydejack/__link__/_content.scss +1 -0
- data/_sass/hydejack/__link__/_footer.scss +6 -8
- data/_sass/hydejack/__link__/_images.scss +8 -39
- data/_sass/hydejack/__link__/_katex.scss +1 -26
- data/_sass/hydejack/__link__/_links.scss +29 -20
- data/_sass/hydejack/__link__/_mark-external.scss +2 -7
- data/_sass/hydejack/__link__/_menu.scss +63 -8
- data/_sass/hydejack/__link__/_sidebar.scss +12 -9
- data/_sass/hydejack/__link__/_toc.scss +53 -0
- data/_sass/hydejack/__link__/_utilities.scss +3 -0
- data/_sass/hydejack/_avatar.pre.scss +10 -12
- data/_sass/hydejack/_base.pre.scss +7 -23
- data/_sass/hydejack/_break-layout.pre.scss +19 -10
- data/_sass/hydejack/_content.pre.scss +10 -2
- data/_sass/hydejack/_footer.pre.scss +6 -8
- data/_sass/hydejack/_images.pre.scss +9 -41
- data/_sass/hydejack/_katex.pre.scss +3 -28
- data/_sass/hydejack/_links.pre.scss +49 -19
- data/_sass/hydejack/_mark-external.pre.scss +2 -7
- data/_sass/hydejack/_menu.pre.scss +91 -22
- data/_sass/hydejack/_sidebar.pre.scss +48 -22
- data/_sass/hydejack/_social.pre.scss +3 -0
- data/_sass/hydejack/_toc.pre.scss +65 -0
- data/_sass/hydejack/_utilities.pre.scss +3 -0
- data/_sass/my-inline.scss +2 -16
- data/_sass/my-style.scss +0 -9
- data/_sass/pooleparty/__inline__/_base.scss +14 -9
- data/_sass/pooleparty/__inline__/_message.scss +31 -0
- data/_sass/pooleparty/__inline__/_posts.scss +19 -2
- data/_sass/pooleparty/__inline__/_table.scss +0 -28
- data/_sass/pooleparty/__inline__/_type.scss +81 -15
- data/_sass/pooleparty/__link__/_base.scss +11 -5
- data/_sass/pooleparty/__link__/_code.scss +40 -7
- data/_sass/pooleparty/__link__/_footnotes.scss +4 -5
- data/_sass/pooleparty/__link__/_pagination.scss +3 -2
- data/_sass/pooleparty/__link__/_posts.scss +11 -6
- data/_sass/pooleparty/__link__/_read-more.scss +1 -1
- data/_sass/pooleparty/__link__/_table.scss +27 -17
- data/_sass/pooleparty/__link__/_type.scss +56 -19
- data/_sass/pooleparty/_base.pre.scss +29 -18
- data/_sass/pooleparty/_code.pre.scss +40 -7
- data/_sass/pooleparty/_footnotes.pre.scss +4 -5
- data/_sass/pooleparty/_message.pre.scss +33 -2
- data/_sass/pooleparty/_pagination.pre.scss +5 -4
- data/_sass/pooleparty/_posts.pre.scss +34 -12
- data/_sass/pooleparty/_read-more.pre.scss +1 -1
- data/_sass/pooleparty/_table.pre.scss +13 -21
- data/_sass/pooleparty/_type.pre.scss +100 -35
- data/assets/bower.json +1 -2
- data/assets/bower_components/MathJax/.bower.json +28 -0
- data/assets/bower_components/MathJax/LICENSE +202 -0
- data/assets/bower_components/MathJax/bower.json +11 -0
- data/assets/bower_components/MathJax/composer.json +14 -0
- data/assets/bower_components/MathJax/es5/a11y/assistive-mml.js +1 -0
- data/assets/bower_components/MathJax/es5/a11y/complexity.js +1 -0
- data/assets/bower_components/MathJax/es5/a11y/explorer.js +1 -0
- data/assets/bower_components/MathJax/es5/a11y/semantic-enrich.js +1 -0
- data/assets/bower_components/MathJax/es5/adaptors/liteDOM.js +1 -0
- data/assets/bower_components/MathJax/es5/core.js +1 -0
- data/assets/bower_components/MathJax/es5/input/asciimath.js +1 -0
- data/assets/bower_components/MathJax/es5/input/mml.js +1 -0
- data/assets/bower_components/MathJax/es5/input/mml/entities.js +1 -0
- data/assets/bower_components/MathJax/es5/input/tex-base.js +1 -0
- data/assets/bower_components/MathJax/es5/input/tex-full.js +1 -0
- data/assets/bower_components/MathJax/es5/input/tex.js +1 -0
- data/assets/bower_components/MathJax/es5/input/tex/extensions/action.js +1 -0
- data/assets/bower_components/MathJax/es5/input/tex/extensions/all-packages.js +1 -0
- data/assets/bower_components/MathJax/es5/input/tex/extensions/ams.js +1 -0
- data/assets/bower_components/MathJax/es5/input/tex/extensions/amscd.js +1 -0
- data/assets/bower_components/MathJax/es5/input/tex/extensions/autoload.js +1 -0
- data/assets/bower_components/MathJax/es5/input/tex/extensions/bbox.js +1 -0
- data/assets/bower_components/MathJax/es5/input/tex/extensions/boldsymbol.js +1 -0
- data/assets/bower_components/MathJax/es5/input/tex/extensions/braket.js +1 -0
- data/assets/bower_components/MathJax/es5/input/tex/extensions/bussproofs.js +1 -0
- data/assets/bower_components/MathJax/es5/input/tex/extensions/cancel.js +1 -0
- data/assets/bower_components/MathJax/es5/input/tex/extensions/color.js +1 -0
- data/assets/bower_components/MathJax/es5/input/tex/extensions/colorV2.js +1 -0
- data/assets/bower_components/MathJax/es5/input/tex/extensions/configMacros.js +1 -0
- data/assets/bower_components/MathJax/es5/input/tex/extensions/enclose.js +1 -0
- data/assets/bower_components/MathJax/es5/input/tex/extensions/extpfeil.js +1 -0
- data/assets/bower_components/MathJax/es5/input/tex/extensions/html.js +1 -0
- data/assets/bower_components/MathJax/es5/input/tex/extensions/mhchem.js +1 -0
- data/assets/bower_components/MathJax/es5/input/tex/extensions/newcommand.js +1 -0
- data/assets/bower_components/MathJax/es5/input/tex/extensions/noerrors.js +1 -0
- data/assets/bower_components/MathJax/es5/input/tex/extensions/noundefined.js +1 -0
- data/assets/bower_components/MathJax/es5/input/tex/extensions/physics.js +1 -0
- data/assets/bower_components/MathJax/es5/input/tex/extensions/require.js +1 -0
- data/assets/bower_components/MathJax/es5/input/tex/extensions/tagFormat.js +1 -0
- data/assets/bower_components/MathJax/es5/input/tex/extensions/unicode.js +1 -0
- data/assets/bower_components/MathJax/es5/input/tex/extensions/verb.js +1 -0
- data/assets/bower_components/MathJax/es5/latest.js +1 -0
- data/assets/bower_components/MathJax/es5/loader.js +1 -0
- data/assets/bower_components/MathJax/es5/mml-chtml.js +1 -0
- data/assets/bower_components/MathJax/es5/mml-svg.js +1 -0
- data/assets/bower_components/MathJax/es5/node-main.js +1 -0
- data/assets/bower_components/MathJax/es5/output/chtml.js +1 -0
- data/assets/bower_components/MathJax/es5/output/chtml/fonts/tex.js +1 -0
- data/assets/bower_components/MathJax/es5/output/chtml/fonts/woff-v2/MathJax_AMS-Regular.woff +0 -0
- data/assets/bower_components/MathJax/es5/output/chtml/fonts/woff-v2/MathJax_Calligraphic-Bold.woff +0 -0
- data/assets/bower_components/MathJax/es5/output/chtml/fonts/woff-v2/MathJax_Calligraphic-Regular.woff +0 -0
- data/assets/bower_components/MathJax/es5/output/chtml/fonts/woff-v2/MathJax_Fraktur-Bold.woff +0 -0
- data/assets/bower_components/MathJax/es5/output/chtml/fonts/woff-v2/MathJax_Fraktur-Regular.woff +0 -0
- data/assets/bower_components/MathJax/es5/output/chtml/fonts/woff-v2/MathJax_Main-Bold.woff +0 -0
- data/assets/bower_components/MathJax/es5/output/chtml/fonts/woff-v2/MathJax_Main-Italic.woff +0 -0
- data/assets/bower_components/MathJax/es5/output/chtml/fonts/woff-v2/MathJax_Main-Regular.woff +0 -0
- data/assets/bower_components/MathJax/es5/output/chtml/fonts/woff-v2/MathJax_Math-BoldItalic.woff +0 -0
- data/assets/bower_components/MathJax/es5/output/chtml/fonts/woff-v2/MathJax_Math-Italic.woff +0 -0
- data/assets/bower_components/MathJax/es5/output/chtml/fonts/woff-v2/MathJax_Math-Regular.woff +0 -0
- data/assets/bower_components/MathJax/es5/output/chtml/fonts/woff-v2/MathJax_SansSerif-Bold.woff +0 -0
- data/assets/bower_components/MathJax/es5/output/chtml/fonts/woff-v2/MathJax_SansSerif-Italic.woff +0 -0
- data/assets/bower_components/MathJax/es5/output/chtml/fonts/woff-v2/MathJax_SansSerif-Regular.woff +0 -0
- data/assets/bower_components/MathJax/es5/output/chtml/fonts/woff-v2/MathJax_Script-Regular.woff +0 -0
- data/assets/bower_components/MathJax/es5/output/chtml/fonts/woff-v2/MathJax_Size1-Regular.woff +0 -0
- data/assets/bower_components/MathJax/es5/output/chtml/fonts/woff-v2/MathJax_Size2-Regular.woff +0 -0
- data/assets/bower_components/MathJax/es5/output/chtml/fonts/woff-v2/MathJax_Size3-Regular.woff +0 -0
- data/assets/bower_components/MathJax/es5/output/chtml/fonts/woff-v2/MathJax_Size4-Regular.woff +0 -0
- data/assets/bower_components/MathJax/es5/output/chtml/fonts/woff-v2/MathJax_Typewriter-Regular.woff +0 -0
- data/assets/bower_components/MathJax/es5/output/chtml/fonts/woff-v2/MathJax_Vector-Bold.woff +0 -0
- data/assets/bower_components/MathJax/es5/output/chtml/fonts/woff-v2/MathJax_Vector-Regular.woff +0 -0
- data/assets/bower_components/MathJax/es5/output/chtml/fonts/woff-v2/MathJax_Zero.woff +0 -0
- data/assets/bower_components/MathJax/es5/output/svg.js +1 -0
- data/assets/bower_components/MathJax/es5/output/svg/fonts/tex.js +1 -0
- data/assets/bower_components/MathJax/es5/sre/mathmaps/en.js +104 -0
- data/assets/bower_components/MathJax/es5/sre/mathmaps/es.js +104 -0
- data/assets/bower_components/MathJax/es5/sre/mathmaps/fr.js +104 -0
- data/assets/bower_components/MathJax/es5/sre/mathmaps/mathmaps_ie.js +410 -0
- data/assets/bower_components/MathJax/es5/sre/mathmaps/nemeth.js +104 -0
- data/assets/bower_components/MathJax/es5/sre/sre_browser.js +1709 -0
- data/assets/bower_components/MathJax/es5/startup.js +1 -0
- data/assets/bower_components/MathJax/es5/tex-chtml-full.js +1 -0
- data/assets/bower_components/MathJax/es5/tex-chtml.js +1 -0
- data/assets/bower_components/MathJax/es5/tex-mml-chtml.js +1 -0
- data/assets/bower_components/MathJax/es5/tex-mml-svg.js +1 -0
- data/assets/bower_components/MathJax/es5/tex-svg-full.js +1 -0
- data/assets/bower_components/MathJax/es5/tex-svg.js +1 -0
- data/assets/bower_components/MathJax/es5/ui/menu.js +1 -0
- data/assets/bower_components/MathJax/package.json +59 -0
- data/assets/bower_components/katex/.bower.json +7 -8
- data/assets/bower_components/katex/bower.json +1 -1
- data/assets/bower_components/katex/dist/contrib/auto-render.js +4 -0
- data/assets/bower_components/katex/dist/contrib/auto-render.min.js +1 -1
- data/assets/bower_components/katex/dist/contrib/auto-render.mjs +215 -0
- data/assets/bower_components/katex/dist/contrib/copy-tex.js +9 -4
- data/assets/bower_components/katex/dist/contrib/copy-tex.min.css +1 -1
- data/assets/bower_components/katex/dist/contrib/copy-tex.min.js +1 -1
- data/assets/bower_components/katex/dist/contrib/copy-tex.mjs +85 -0
- data/assets/bower_components/katex/dist/contrib/mathtex-script-type.min.js +1 -1
- data/assets/bower_components/katex/dist/contrib/mathtex-script-type.mjs +24 -0
- data/assets/bower_components/katex/dist/contrib/mhchem.js +3241 -0
- data/assets/bower_components/katex/dist/contrib/mhchem.min.js +1 -0
- data/assets/bower_components/katex/dist/contrib/mhchem.mjs +3109 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_AMS-Regular.ttf +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_AMS-Regular.woff +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_AMS-Regular.woff2 +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_Caligraphic-Bold.ttf +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_Caligraphic-Bold.woff +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_Caligraphic-Regular.ttf +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_Caligraphic-Regular.woff +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_Fraktur-Bold.ttf +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_Fraktur-Bold.woff +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_Fraktur-Regular.ttf +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_Fraktur-Regular.woff +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_Main-Bold.ttf +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_Main-Bold.woff +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_Main-Bold.woff2 +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_Main-BoldItalic.ttf +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_Main-BoldItalic.woff +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_Main-Italic.ttf +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_Main-Italic.woff +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_Main-Italic.woff2 +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_Main-Regular.ttf +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_Main-Regular.woff +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_Main-Regular.woff2 +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_Math-BoldItalic.ttf +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_Math-BoldItalic.woff +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_Math-Italic.ttf +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_Math-Italic.woff +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_Math-Italic.woff2 +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_SansSerif-Bold.ttf +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_SansSerif-Bold.woff +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_SansSerif-Italic.ttf +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_SansSerif-Italic.woff +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_SansSerif-Regular.ttf +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_SansSerif-Regular.woff +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_Script-Regular.ttf +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_Script-Regular.woff +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_Script-Regular.woff2 +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_Size1-Regular.ttf +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_Size1-Regular.woff +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_Size1-Regular.woff2 +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_Size2-Regular.ttf +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_Size2-Regular.woff +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_Size2-Regular.woff2 +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_Size3-Regular.ttf +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_Size3-Regular.woff +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_Size3-Regular.woff2 +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_Size4-Regular.ttf +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_Size4-Regular.woff +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_Size4-Regular.woff2 +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_Typewriter-Regular.ttf +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_Typewriter-Regular.woff +0 -0
- data/assets/bower_components/katex/dist/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
- data/assets/bower_components/katex/dist/katex.css +18 -4
- data/assets/bower_components/katex/dist/katex.js +1011 -663
- data/assets/bower_components/katex/dist/katex.min.css +1 -1
- data/assets/bower_components/katex/dist/katex.min.js +1 -1
- data/assets/bower_components/katex/dist/katex.mjs +904 -645
- data/assets/bower_components/katex/yarn.lock +3091 -2622
- data/assets/css/{hydejack-8.3.2.css → hydejack-9.0.0.css} +0 -0
- data/assets/icomoon/fonts/icomoon.eot +0 -0
- data/assets/icomoon/fonts/icomoon.svg +10 -2
- data/assets/icomoon/fonts/icomoon.ttf +0 -0
- data/assets/icomoon/fonts/icomoon.woff +0 -0
- data/assets/icomoon/selection.json +1 -2555
- data/assets/icomoon/style.css +37 -12
- data/assets/js/.gitkeep +0 -0
- data/assets/js/LEGACY-drawer-hydejack-9.0.0.js +14 -0
- data/assets/js/LEGACY-fetch-hydejack-9.0.0.js +14 -0
- data/assets/js/LEGACY-hydejack-9.0.0.js +28 -0
- data/assets/js/LEGACY-navbar-hydejack-9.0.0.js +14 -0
- data/assets/js/LEGACY-push-state-hydejack-9.0.0.js +14 -0
- data/assets/js/LEGACY-resize-observer-hydejack-9.0.0.js +14 -0
- data/assets/js/LEGACY-shadydom-hydejack-9.0.0.js +14 -0
- data/assets/js/LEGACY-vendors~drawer-hydejack-9.0.0.js +47 -0
- data/assets/js/LEGACY-vendors~drawer~push-state-hydejack-9.0.0.js +215 -0
- data/assets/js/LEGACY-vendors~fetch-hydejack-9.0.0.js +14 -0
- data/assets/js/LEGACY-vendors~intersection-observer-hydejack-9.0.0.js +14 -0
- data/assets/js/LEGACY-vendors~push-state-hydejack-9.0.0.js +33 -0
- data/assets/js/LEGACY-vendors~shadydom-hydejack-9.0.0.js +155 -0
- data/assets/js/LEGACY-vendors~webanimations-hydejack-9.0.0.js +14 -0
- data/assets/js/LEGACY-vendors~webcomponents-hydejack-9.0.0.js +34 -0
- data/assets/js/LEGACY-webcomponents-hydejack-9.0.0.js +14 -0
- data/assets/js/drawer-hydejack-9.0.0.js +14 -0
- data/assets/js/fetch-hydejack-9.0.0.js +14 -0
- data/assets/js/hydejack-9.0.0.js +28 -0
- data/assets/js/navbar-hydejack-9.0.0.js +14 -0
- data/assets/js/push-state-hydejack-9.0.0.js +14 -0
- data/assets/js/resize-observer-hydejack-9.0.0.js +14 -0
- data/assets/js/shadydom-hydejack-9.0.0.js +14 -0
- data/assets/js/vendors~drawer-hydejack-9.0.0.js +47 -0
- data/assets/js/vendors~drawer~push-state-hydejack-9.0.0.js +163 -0
- data/assets/js/vendors~intersection-observer-hydejack-9.0.0.js +14 -0
- data/assets/js/vendors~push-state-hydejack-9.0.0.js +33 -0
- data/assets/js/vendors~shadydom-hydejack-9.0.0.js +146 -0
- data/assets/js/vendors~webanimations-hydejack-9.0.0.js +14 -0
- data/assets/js/webcomponents-hydejack-9.0.0.js +14 -0
- data/assets/version.json +3 -2
- data/licenses/PRO.md +4 -0
- data/licenses/README.md +1 -1
- data/licenses/{W3C.md → W3C-20150513.md} +0 -0
- metadata +170 -55
- data/assets/Resume.pdf +0 -0
- data/assets/bower_components/fontfaceobserver/.bower.json +0 -33
- data/assets/bower_components/fontfaceobserver/.gitignore +0 -2
- data/assets/bower_components/fontfaceobserver/.travis.yml +0 -16
- data/assets/bower_components/fontfaceobserver/Gruntfile.js +0 -101
- data/assets/bower_components/fontfaceobserver/LICENSE +0 -23
- data/assets/bower_components/fontfaceobserver/bower.json +0 -22
- data/assets/bower_components/fontfaceobserver/exports.js +0 -8
- data/assets/bower_components/fontfaceobserver/externs-commonjs.js +0 -10
- data/assets/bower_components/fontfaceobserver/externs.js +0 -15
- data/assets/bower_components/fontfaceobserver/fontfaceobserver.js +0 -12
- data/assets/bower_components/fontfaceobserver/fontfaceobserver.standalone.js +0 -8
- data/assets/bower_components/fontfaceobserver/package.json +0 -57
- data/assets/bower_components/fontfaceobserver/src/descriptors.js +0 -10
- data/assets/bower_components/fontfaceobserver/src/observer.js +0 -349
- data/assets/bower_components/fontfaceobserver/src/ruler.js +0 -130
- data/assets/bower_components/fontfaceobserver/vendor/google/base.js +0 -1489
- data/assets/bower_components/katex/dist/README.md +0 -90
- data/assets/bower_components/katex/lint_blacklist.txt +0 -5
- data/assets/img/blog/COLOURlovers.com-Hydejack.png +0 -0
- data/assets/img/blog/blog-layout.jpg +0 -0
- data/assets/img/blog/caleb-george-old.jpg +0 -0
- data/assets/img/blog/caleb-george.jpg +0 -0
- data/assets/img/blog/cover-page.jpg +0 -0
- data/assets/img/blog/dark-mode-ii.jpg +0 -0
- data/assets/img/blog/dark-mode.jpg +0 -0
- data/assets/img/blog/example-content-ii.jpg +0 -0
- data/assets/img/blog/example-content-iii.jpg +0 -0
- data/assets/img/blog/hydejack-8.png +0 -0
- data/assets/img/blog/hydejack-8@0,25x.png +0 -0
- data/assets/img/blog/hydejack-8@0,5x.png +0 -0
- data/assets/img/blog/lazy-images.jpg +0 -0
- data/assets/img/blog/resume.png +0 -0
- data/assets/img/blog/steve-harvey.jpg +0 -0
- data/assets/img/blog/w3m.png +0 -0
- data/assets/img/blog/wade-lambert.jpg +0 -0
- data/assets/img/docs/google-fonts.png +0 -0
- data/assets/img/projects/hy-drawer.svg +0 -12
- data/assets/img/projects/hy-img.svg +0 -17
- data/assets/img/projects/hy-push-state.svg +0 -13
- data/assets/js/hydejack-8.3.1.js +0 -47
- data/assets/js/hydejack-8.3.2.js +0 -47
- data/assets/video/blog-layout.mp4 +0 -0
- data/assets/video/cover-page.mp4 +0 -0
- data/assets/video/dark-mode.mp4 +0 -0
- data/assets/video/lazy-images.mp4 +0 -0
@@ -1 +1 @@
|
|
1
|
-
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("katex"));else if("function"==typeof define&&define.amd)define(["katex"],t);else{var r="object"==typeof exports?t(require("katex")):t(e.katex);for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}("undefined"!=typeof self?self:this,function(
|
1
|
+
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("katex"));else if("function"==typeof define&&define.amd)define(["katex"],t);else{var r="object"==typeof exports?t(require("katex")):t(e.katex);for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}("undefined"!=typeof self?self:this,function(e){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=1)}([function(t,r){t.exports=e},function(e,t,r){"use strict";r.r(t);var n=r(0),o=r.n(n),u=document.body.getElementsByTagName("script");(u=Array.prototype.slice.call(u)).forEach(function(e){if(!e.type||!e.type.match(/math\/tex/i))return-1;var t=null!=e.type.match(/mode\s*=\s*display(;|\s|\n|$)/),r=document.createElement(t?"div":"span");r.setAttribute("class",t?"equation":"inline-equation");try{o.a.render(e.text,r,{displayMode:t})}catch(t){r.textContent=e.text}e.parentNode.replaceChild(r,e)})}]).default});
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import katex from '../katex.mjs';
|
2
|
+
|
3
|
+
let scripts = document.body.getElementsByTagName("script");
|
4
|
+
scripts = Array.prototype.slice.call(scripts);
|
5
|
+
scripts.forEach(function (script) {
|
6
|
+
if (!script.type || !script.type.match(/math\/tex/i)) {
|
7
|
+
return -1;
|
8
|
+
}
|
9
|
+
|
10
|
+
const display = script.type.match(/mode\s*=\s*display(;|\s|\n|$)/) != null;
|
11
|
+
const katexElement = document.createElement(display ? "div" : "span");
|
12
|
+
katexElement.setAttribute("class", display ? "equation" : "inline-equation");
|
13
|
+
|
14
|
+
try {
|
15
|
+
katex.render(script.text, katexElement, {
|
16
|
+
displayMode: display
|
17
|
+
});
|
18
|
+
} catch (err) {
|
19
|
+
//console.error(err); linter doesn't like this
|
20
|
+
katexElement.textContent = script.text;
|
21
|
+
}
|
22
|
+
|
23
|
+
script.parentNode.replaceChild(katexElement, script);
|
24
|
+
});
|
@@ -0,0 +1,3241 @@
|
|
1
|
+
(function webpackUniversalModuleDefinition(root, factory) {
|
2
|
+
if(typeof exports === 'object' && typeof module === 'object')
|
3
|
+
module.exports = factory(require("katex"));
|
4
|
+
else if(typeof define === 'function' && define.amd)
|
5
|
+
define(["katex"], factory);
|
6
|
+
else {
|
7
|
+
var a = typeof exports === 'object' ? factory(require("katex")) : factory(root["katex"]);
|
8
|
+
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
|
9
|
+
}
|
10
|
+
})((typeof self !== 'undefined' ? self : this), function(__WEBPACK_EXTERNAL_MODULE__0__) {
|
11
|
+
return /******/ (function(modules) { // webpackBootstrap
|
12
|
+
/******/ // The module cache
|
13
|
+
/******/ var installedModules = {};
|
14
|
+
/******/
|
15
|
+
/******/ // The require function
|
16
|
+
/******/ function __webpack_require__(moduleId) {
|
17
|
+
/******/
|
18
|
+
/******/ // Check if module is in cache
|
19
|
+
/******/ if(installedModules[moduleId]) {
|
20
|
+
/******/ return installedModules[moduleId].exports;
|
21
|
+
/******/ }
|
22
|
+
/******/ // Create a new module (and put it into the cache)
|
23
|
+
/******/ var module = installedModules[moduleId] = {
|
24
|
+
/******/ i: moduleId,
|
25
|
+
/******/ l: false,
|
26
|
+
/******/ exports: {}
|
27
|
+
/******/ };
|
28
|
+
/******/
|
29
|
+
/******/ // Execute the module function
|
30
|
+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
31
|
+
/******/
|
32
|
+
/******/ // Flag the module as loaded
|
33
|
+
/******/ module.l = true;
|
34
|
+
/******/
|
35
|
+
/******/ // Return the exports of the module
|
36
|
+
/******/ return module.exports;
|
37
|
+
/******/ }
|
38
|
+
/******/
|
39
|
+
/******/
|
40
|
+
/******/ // expose the modules object (__webpack_modules__)
|
41
|
+
/******/ __webpack_require__.m = modules;
|
42
|
+
/******/
|
43
|
+
/******/ // expose the module cache
|
44
|
+
/******/ __webpack_require__.c = installedModules;
|
45
|
+
/******/
|
46
|
+
/******/ // define getter function for harmony exports
|
47
|
+
/******/ __webpack_require__.d = function(exports, name, getter) {
|
48
|
+
/******/ if(!__webpack_require__.o(exports, name)) {
|
49
|
+
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
50
|
+
/******/ }
|
51
|
+
/******/ };
|
52
|
+
/******/
|
53
|
+
/******/ // define __esModule on exports
|
54
|
+
/******/ __webpack_require__.r = function(exports) {
|
55
|
+
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
56
|
+
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
57
|
+
/******/ }
|
58
|
+
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
59
|
+
/******/ };
|
60
|
+
/******/
|
61
|
+
/******/ // create a fake namespace object
|
62
|
+
/******/ // mode & 1: value is a module id, require it
|
63
|
+
/******/ // mode & 2: merge all properties of value into the ns
|
64
|
+
/******/ // mode & 4: return value when already ns object
|
65
|
+
/******/ // mode & 8|1: behave like require
|
66
|
+
/******/ __webpack_require__.t = function(value, mode) {
|
67
|
+
/******/ if(mode & 1) value = __webpack_require__(value);
|
68
|
+
/******/ if(mode & 8) return value;
|
69
|
+
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
70
|
+
/******/ var ns = Object.create(null);
|
71
|
+
/******/ __webpack_require__.r(ns);
|
72
|
+
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
73
|
+
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
74
|
+
/******/ return ns;
|
75
|
+
/******/ };
|
76
|
+
/******/
|
77
|
+
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
78
|
+
/******/ __webpack_require__.n = function(module) {
|
79
|
+
/******/ var getter = module && module.__esModule ?
|
80
|
+
/******/ function getDefault() { return module['default']; } :
|
81
|
+
/******/ function getModuleExports() { return module; };
|
82
|
+
/******/ __webpack_require__.d(getter, 'a', getter);
|
83
|
+
/******/ return getter;
|
84
|
+
/******/ };
|
85
|
+
/******/
|
86
|
+
/******/ // Object.prototype.hasOwnProperty.call
|
87
|
+
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
88
|
+
/******/
|
89
|
+
/******/ // __webpack_public_path__
|
90
|
+
/******/ __webpack_require__.p = "";
|
91
|
+
/******/
|
92
|
+
/******/
|
93
|
+
/******/ // Load entry module and return exports
|
94
|
+
/******/ return __webpack_require__(__webpack_require__.s = 1);
|
95
|
+
/******/ })
|
96
|
+
/************************************************************************/
|
97
|
+
/******/ ([
|
98
|
+
/* 0 */
|
99
|
+
/***/ (function(module, exports) {
|
100
|
+
|
101
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE__0__;
|
102
|
+
|
103
|
+
/***/ }),
|
104
|
+
/* 1 */
|
105
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
106
|
+
|
107
|
+
"use strict";
|
108
|
+
__webpack_require__.r(__webpack_exports__);
|
109
|
+
/* harmony import */ var katex__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
|
110
|
+
/* harmony import */ var katex__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(katex__WEBPACK_IMPORTED_MODULE_0__);
|
111
|
+
/* eslint-disable */
|
112
|
+
|
113
|
+
/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
|
114
|
+
|
115
|
+
/* vim: set ts=2 et sw=2 tw=80: */
|
116
|
+
|
117
|
+
/*************************************************************
|
118
|
+
*
|
119
|
+
* KaTeX mhchem.js
|
120
|
+
*
|
121
|
+
* This file implements a KaTeX version of mhchem version 3.3.0.
|
122
|
+
* It is adapted from MathJax/extensions/TeX/mhchem.js
|
123
|
+
* It differs from the MathJax version as follows:
|
124
|
+
* 1. The interface is changed so that it can be called from KaTeX, not MathJax.
|
125
|
+
* 2. \rlap and \llap are replaced with \mathrlap and \mathllap.
|
126
|
+
* 3. Four lines of code are edited in order to use \raisebox instead of \raise.
|
127
|
+
* 4. The reaction arrow code is simplified. All reaction arrows are rendered
|
128
|
+
* using KaTeX extensible arrows instead of building non-extensible arrows.
|
129
|
+
* 5. \tripledash vertical alignment is slightly adjusted.
|
130
|
+
*
|
131
|
+
* This code, as other KaTeX code, is released under the MIT license.
|
132
|
+
*
|
133
|
+
* /*************************************************************
|
134
|
+
*
|
135
|
+
* MathJax/extensions/TeX/mhchem.js
|
136
|
+
*
|
137
|
+
* Implements the \ce command for handling chemical formulas
|
138
|
+
* from the mhchem LaTeX package.
|
139
|
+
*
|
140
|
+
* ---------------------------------------------------------------------
|
141
|
+
*
|
142
|
+
* Copyright (c) 2011-2015 The MathJax Consortium
|
143
|
+
* Copyright (c) 2015-2018 Martin Hensel
|
144
|
+
*
|
145
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
146
|
+
* you may not use this file except in compliance with the License.
|
147
|
+
* You may obtain a copy of the License at
|
148
|
+
*
|
149
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
150
|
+
*
|
151
|
+
* Unless required by applicable law or agreed to in writing, software
|
152
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
153
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
154
|
+
* See the License for the specific language governing permissions and
|
155
|
+
* limitations under the License.
|
156
|
+
*/
|
157
|
+
//
|
158
|
+
// Coding Style
|
159
|
+
// - use '' for identifiers that can by minified/uglified
|
160
|
+
// - use "" for strings that need to stay untouched
|
161
|
+
// version: "3.3.0" for MathJax and KaTeX
|
162
|
+
// Add \ce, \pu, and \tripledash to the KaTeX macros.
|
163
|
+
katex__WEBPACK_IMPORTED_MODULE_0___default.a.__defineMacro("\\ce", function (context) {
|
164
|
+
return chemParse(context.consumeArgs(1)[0], "ce");
|
165
|
+
});
|
166
|
+
|
167
|
+
katex__WEBPACK_IMPORTED_MODULE_0___default.a.__defineMacro("\\pu", function (context) {
|
168
|
+
return chemParse(context.consumeArgs(1)[0], "pu");
|
169
|
+
}); // Needed for \bond for the ~ forms
|
170
|
+
// Raise by 2.56mu, not 2mu. We're raising a hyphen-minus, U+002D, not
|
171
|
+
// a mathematical minus, U+2212. So we need that extra 0.56.
|
172
|
+
|
173
|
+
|
174
|
+
katex__WEBPACK_IMPORTED_MODULE_0___default.a.__defineMacro("\\tripledash", "{\\vphantom{-}\\raisebox{2.56mu}{$\\mkern2mu" + "\\tiny\\text{-}\\mkern1mu\\text{-}\\mkern1mu\\text{-}\\mkern2mu$}}");
|
175
|
+
|
176
|
+
//
|
177
|
+
// This is the main function for handing the \ce and \pu commands.
|
178
|
+
// It takes the argument to \ce or \pu and returns the corresponding TeX string.
|
179
|
+
//
|
180
|
+
|
181
|
+
var chemParse = function chemParse(tokens, stateMachine) {
|
182
|
+
// Recreate the argument string from KaTeX's array of tokens.
|
183
|
+
var str = "";
|
184
|
+
var expectedLoc = tokens[tokens.length - 1].loc.start;
|
185
|
+
|
186
|
+
for (var i = tokens.length - 1; i >= 0; i--) {
|
187
|
+
if (tokens[i].loc.start > expectedLoc) {
|
188
|
+
// context.consumeArgs has eaten a space.
|
189
|
+
str += " ";
|
190
|
+
expectedLoc = tokens[i].loc.start;
|
191
|
+
}
|
192
|
+
|
193
|
+
str += tokens[i].text;
|
194
|
+
expectedLoc += tokens[i].text.length;
|
195
|
+
}
|
196
|
+
|
197
|
+
var tex = texify.go(mhchemParser.go(str, stateMachine));
|
198
|
+
return tex;
|
199
|
+
}; //
|
200
|
+
// Core parser for mhchem syntax (recursive)
|
201
|
+
//
|
202
|
+
|
203
|
+
/** @type {MhchemParser} */
|
204
|
+
|
205
|
+
|
206
|
+
var mhchemParser = {
|
207
|
+
//
|
208
|
+
// Parses mchem \ce syntax
|
209
|
+
//
|
210
|
+
// Call like
|
211
|
+
// go("H2O");
|
212
|
+
//
|
213
|
+
go: function go(input, stateMachine) {
|
214
|
+
if (!input) {
|
215
|
+
return [];
|
216
|
+
}
|
217
|
+
|
218
|
+
if (stateMachine === undefined) {
|
219
|
+
stateMachine = 'ce';
|
220
|
+
}
|
221
|
+
|
222
|
+
var state = '0'; //
|
223
|
+
// String buffers for parsing:
|
224
|
+
//
|
225
|
+
// buffer.a == amount
|
226
|
+
// buffer.o == element
|
227
|
+
// buffer.b == left-side superscript
|
228
|
+
// buffer.p == left-side subscript
|
229
|
+
// buffer.q == right-side subscript
|
230
|
+
// buffer.d == right-side superscript
|
231
|
+
//
|
232
|
+
// buffer.r == arrow
|
233
|
+
// buffer.rdt == arrow, script above, type
|
234
|
+
// buffer.rd == arrow, script above, content
|
235
|
+
// buffer.rqt == arrow, script below, type
|
236
|
+
// buffer.rq == arrow, script below, content
|
237
|
+
//
|
238
|
+
// buffer.text_
|
239
|
+
// buffer.rm
|
240
|
+
// etc.
|
241
|
+
//
|
242
|
+
// buffer.parenthesisLevel == int, starting at 0
|
243
|
+
// buffer.sb == bool, space before
|
244
|
+
// buffer.beginsWithBond == bool
|
245
|
+
//
|
246
|
+
// These letters are also used as state names.
|
247
|
+
//
|
248
|
+
// Other states:
|
249
|
+
// 0 == begin of main part (arrow/operator unlikely)
|
250
|
+
// 1 == next entity
|
251
|
+
// 2 == next entity (arrow/operator unlikely)
|
252
|
+
// 3 == next atom
|
253
|
+
// c == macro
|
254
|
+
//
|
255
|
+
|
256
|
+
/** @type {Buffer} */
|
257
|
+
|
258
|
+
var buffer = {};
|
259
|
+
buffer['parenthesisLevel'] = 0;
|
260
|
+
input = input.replace(/\n/g, " ");
|
261
|
+
input = input.replace(/[\u2212\u2013\u2014\u2010]/g, "-");
|
262
|
+
input = input.replace(/[\u2026]/g, "..."); //
|
263
|
+
// Looks through mhchemParser.transitions, to execute a matching action
|
264
|
+
// (recursive)
|
265
|
+
//
|
266
|
+
|
267
|
+
var lastInput;
|
268
|
+
var watchdog = 10;
|
269
|
+
/** @type {ParserOutput[]} */
|
270
|
+
|
271
|
+
var output = [];
|
272
|
+
|
273
|
+
while (true) {
|
274
|
+
if (lastInput !== input) {
|
275
|
+
watchdog = 10;
|
276
|
+
lastInput = input;
|
277
|
+
} else {
|
278
|
+
watchdog--;
|
279
|
+
} //
|
280
|
+
// Find actions in transition table
|
281
|
+
//
|
282
|
+
|
283
|
+
|
284
|
+
var machine = mhchemParser.stateMachines[stateMachine];
|
285
|
+
var t = machine.transitions[state] || machine.transitions['*'];
|
286
|
+
|
287
|
+
iterateTransitions: for (var i = 0; i < t.length; i++) {
|
288
|
+
var matches = mhchemParser.patterns.match_(t[i].pattern, input);
|
289
|
+
|
290
|
+
if (matches) {
|
291
|
+
//
|
292
|
+
// Execute actions
|
293
|
+
//
|
294
|
+
var task = t[i].task;
|
295
|
+
|
296
|
+
for (var iA = 0; iA < task.action_.length; iA++) {
|
297
|
+
var o; //
|
298
|
+
// Find and execute action
|
299
|
+
//
|
300
|
+
|
301
|
+
if (machine.actions[task.action_[iA].type_]) {
|
302
|
+
o = machine.actions[task.action_[iA].type_](buffer, matches.match_, task.action_[iA].option);
|
303
|
+
} else if (mhchemParser.actions[task.action_[iA].type_]) {
|
304
|
+
o = mhchemParser.actions[task.action_[iA].type_](buffer, matches.match_, task.action_[iA].option);
|
305
|
+
} else {
|
306
|
+
throw ["MhchemBugA", "mhchem bug A. Please report. (" + task.action_[iA].type_ + ")"]; // Trying to use non-existing action
|
307
|
+
} //
|
308
|
+
// Add output
|
309
|
+
//
|
310
|
+
|
311
|
+
|
312
|
+
mhchemParser.concatArray(output, o);
|
313
|
+
} //
|
314
|
+
// Set next state,
|
315
|
+
// Shorten input,
|
316
|
+
// Continue with next character
|
317
|
+
// (= apply only one transition per position)
|
318
|
+
//
|
319
|
+
|
320
|
+
|
321
|
+
state = task.nextState || state;
|
322
|
+
|
323
|
+
if (input.length > 0) {
|
324
|
+
if (!task.revisit) {
|
325
|
+
input = matches.remainder;
|
326
|
+
}
|
327
|
+
|
328
|
+
if (!task.toContinue) {
|
329
|
+
break iterateTransitions;
|
330
|
+
}
|
331
|
+
} else {
|
332
|
+
return output;
|
333
|
+
}
|
334
|
+
}
|
335
|
+
} //
|
336
|
+
// Prevent infinite loop
|
337
|
+
//
|
338
|
+
|
339
|
+
|
340
|
+
if (watchdog <= 0) {
|
341
|
+
throw ["MhchemBugU", "mhchem bug U. Please report."]; // Unexpected character
|
342
|
+
}
|
343
|
+
}
|
344
|
+
},
|
345
|
+
concatArray: function concatArray(a, b) {
|
346
|
+
if (b) {
|
347
|
+
if (Array.isArray(b)) {
|
348
|
+
for (var iB = 0; iB < b.length; iB++) {
|
349
|
+
a.push(b[iB]);
|
350
|
+
}
|
351
|
+
} else {
|
352
|
+
a.push(b);
|
353
|
+
}
|
354
|
+
}
|
355
|
+
},
|
356
|
+
patterns: {
|
357
|
+
//
|
358
|
+
// Matching patterns
|
359
|
+
// either regexps or function that return null or {match_:"a", remainder:"bc"}
|
360
|
+
//
|
361
|
+
patterns: {
|
362
|
+
// property names must not look like integers ("2") for correct property traversal order, later on
|
363
|
+
'empty': /^$/,
|
364
|
+
'else': /^./,
|
365
|
+
'else2': /^./,
|
366
|
+
'space': /^\s/,
|
367
|
+
'space A': /^\s(?=[A-Z\\$])/,
|
368
|
+
'space$': /^\s$/,
|
369
|
+
'a-z': /^[a-z]/,
|
370
|
+
'x': /^x/,
|
371
|
+
'x$': /^x$/,
|
372
|
+
'i$': /^i$/,
|
373
|
+
'letters': /^(?:[a-zA-Z\u03B1-\u03C9\u0391-\u03A9?@]|(?:\\(?:alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|psi|omega|Gamma|Delta|Theta|Lambda|Xi|Pi|Sigma|Upsilon|Phi|Psi|Omega)(?:\s+|\{\}|(?![a-zA-Z]))))+/,
|
374
|
+
'\\greek': /^\\(?:alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|psi|omega|Gamma|Delta|Theta|Lambda|Xi|Pi|Sigma|Upsilon|Phi|Psi|Omega)(?:\s+|\{\}|(?![a-zA-Z]))/,
|
375
|
+
'one lowercase latin letter $': /^(?:([a-z])(?:$|[^a-zA-Z]))$/,
|
376
|
+
'$one lowercase latin letter$ $': /^\$(?:([a-z])(?:$|[^a-zA-Z]))\$$/,
|
377
|
+
'one lowercase greek letter $': /^(?:\$?[\u03B1-\u03C9]\$?|\$?\\(?:alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|psi|omega)\s*\$?)(?:\s+|\{\}|(?![a-zA-Z]))$/,
|
378
|
+
'digits': /^[0-9]+/,
|
379
|
+
'-9.,9': /^[+\-]?(?:[0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+))/,
|
380
|
+
'-9.,9 no missing 0': /^[+\-]?[0-9]+(?:[.,][0-9]+)?/,
|
381
|
+
'(-)(9.,9)(e)(99)': function e99(input) {
|
382
|
+
var m = input.match(/^(\+\-|\+\/\-|\+|\-|\\pm\s?)?([0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+))?(\((?:[0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+))\))?(?:([eE]|\s*(\*|x|\\times|\u00D7)\s*10\^)([+\-]?[0-9]+|\{[+\-]?[0-9]+\}))?/);
|
383
|
+
|
384
|
+
if (m && m[0]) {
|
385
|
+
return {
|
386
|
+
match_: m.splice(1),
|
387
|
+
remainder: input.substr(m[0].length)
|
388
|
+
};
|
389
|
+
}
|
390
|
+
|
391
|
+
return null;
|
392
|
+
},
|
393
|
+
'(-)(9)^(-9)': function _(input) {
|
394
|
+
var m = input.match(/^(\+\-|\+\/\-|\+|\-|\\pm\s?)?([0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+)?)\^([+\-]?[0-9]+|\{[+\-]?[0-9]+\})/);
|
395
|
+
|
396
|
+
if (m && m[0]) {
|
397
|
+
return {
|
398
|
+
match_: m.splice(1),
|
399
|
+
remainder: input.substr(m[0].length)
|
400
|
+
};
|
401
|
+
}
|
402
|
+
|
403
|
+
return null;
|
404
|
+
},
|
405
|
+
'state of aggregation $': function stateOfAggregation$(input) {
|
406
|
+
// ... or crystal system
|
407
|
+
var a = mhchemParser.patterns.findObserveGroups(input, "", /^\([a-z]{1,3}(?=[\),])/, ")", ""); // (aq), (aq,$\infty$), (aq, sat)
|
408
|
+
|
409
|
+
if (a && a.remainder.match(/^($|[\s,;\)\]\}])/)) {
|
410
|
+
return a;
|
411
|
+
} // AND end of 'phrase'
|
412
|
+
|
413
|
+
|
414
|
+
var m = input.match(/^(?:\((?:\\ca\s?)?\$[amothc]\$\))/); // OR crystal system ($o$) (\ca$c$)
|
415
|
+
|
416
|
+
if (m) {
|
417
|
+
return {
|
418
|
+
match_: m[0],
|
419
|
+
remainder: input.substr(m[0].length)
|
420
|
+
};
|
421
|
+
}
|
422
|
+
|
423
|
+
return null;
|
424
|
+
},
|
425
|
+
'_{(state of aggregation)}$': /^_\{(\([a-z]{1,3}\))\}/,
|
426
|
+
'{[(': /^(?:\\\{|\[|\()/,
|
427
|
+
')]}': /^(?:\)|\]|\\\})/,
|
428
|
+
', ': /^[,;]\s*/,
|
429
|
+
',': /^[,;]/,
|
430
|
+
'.': /^[.]/,
|
431
|
+
'. ': /^([.\u22C5\u00B7\u2022])\s*/,
|
432
|
+
'...': /^\.\.\.(?=$|[^.])/,
|
433
|
+
'* ': /^([*])\s*/,
|
434
|
+
'^{(...)}': function _(input) {
|
435
|
+
return mhchemParser.patterns.findObserveGroups(input, "^{", "", "", "}");
|
436
|
+
},
|
437
|
+
'^($...$)': function $$(input) {
|
438
|
+
return mhchemParser.patterns.findObserveGroups(input, "^", "$", "$", "");
|
439
|
+
},
|
440
|
+
'^a': /^\^([0-9]+|[^\\_])/,
|
441
|
+
'^\\x{}{}': function x(input) {
|
442
|
+
return mhchemParser.patterns.findObserveGroups(input, "^", /^\\[a-zA-Z]+\{/, "}", "", "", "{", "}", "", true);
|
443
|
+
},
|
444
|
+
'^\\x{}': function x(input) {
|
445
|
+
return mhchemParser.patterns.findObserveGroups(input, "^", /^\\[a-zA-Z]+\{/, "}", "");
|
446
|
+
},
|
447
|
+
'^\\x': /^\^(\\[a-zA-Z]+)\s*/,
|
448
|
+
'^(-1)': /^\^(-?\d+)/,
|
449
|
+
'\'': /^'/,
|
450
|
+
'_{(...)}': function _(input) {
|
451
|
+
return mhchemParser.patterns.findObserveGroups(input, "_{", "", "", "}");
|
452
|
+
},
|
453
|
+
'_($...$)': function _$$(input) {
|
454
|
+
return mhchemParser.patterns.findObserveGroups(input, "_", "$", "$", "");
|
455
|
+
},
|
456
|
+
'_9': /^_([+\-]?[0-9]+|[^\\])/,
|
457
|
+
'_\\x{}{}': function _X(input) {
|
458
|
+
return mhchemParser.patterns.findObserveGroups(input, "_", /^\\[a-zA-Z]+\{/, "}", "", "", "{", "}", "", true);
|
459
|
+
},
|
460
|
+
'_\\x{}': function _X(input) {
|
461
|
+
return mhchemParser.patterns.findObserveGroups(input, "_", /^\\[a-zA-Z]+\{/, "}", "");
|
462
|
+
},
|
463
|
+
'_\\x': /^_(\\[a-zA-Z]+)\s*/,
|
464
|
+
'^_': /^(?:\^(?=_)|\_(?=\^)|[\^_]$)/,
|
465
|
+
'{}': /^\{\}/,
|
466
|
+
'{...}': function _(input) {
|
467
|
+
return mhchemParser.patterns.findObserveGroups(input, "", "{", "}", "");
|
468
|
+
},
|
469
|
+
'{(...)}': function _(input) {
|
470
|
+
return mhchemParser.patterns.findObserveGroups(input, "{", "", "", "}");
|
471
|
+
},
|
472
|
+
'$...$': function $$(input) {
|
473
|
+
return mhchemParser.patterns.findObserveGroups(input, "", "$", "$", "");
|
474
|
+
},
|
475
|
+
'${(...)}$': function $$(input) {
|
476
|
+
return mhchemParser.patterns.findObserveGroups(input, "${", "", "", "}$");
|
477
|
+
},
|
478
|
+
'$(...)$': function $$(input) {
|
479
|
+
return mhchemParser.patterns.findObserveGroups(input, "$", "", "", "$");
|
480
|
+
},
|
481
|
+
'=<>': /^[=<>]/,
|
482
|
+
'#': /^[#\u2261]/,
|
483
|
+
'+': /^\+/,
|
484
|
+
'-$': /^-(?=[\s_},;\]/]|$|\([a-z]+\))/,
|
485
|
+
// -space -, -; -] -/ -$ -state-of-aggregation
|
486
|
+
'-9': /^-(?=[0-9])/,
|
487
|
+
'- orbital overlap': /^-(?=(?:[spd]|sp)(?:$|[\s,;\)\]\}]))/,
|
488
|
+
'-': /^-/,
|
489
|
+
'pm-operator': /^(?:\\pm|\$\\pm\$|\+-|\+\/-)/,
|
490
|
+
'operator': /^(?:\+|(?:[\-=<>]|<<|>>|\\approx|\$\\approx\$)(?=\s|$|-?[0-9]))/,
|
491
|
+
'arrowUpDown': /^(?:v|\(v\)|\^|\(\^\))(?=$|[\s,;\)\]\}])/,
|
492
|
+
'\\bond{(...)}': function bond(input) {
|
493
|
+
return mhchemParser.patterns.findObserveGroups(input, "\\bond{", "", "", "}");
|
494
|
+
},
|
495
|
+
'->': /^(?:<->|<-->|->|<-|<=>>|<<=>|<=>|[\u2192\u27F6\u21CC])/,
|
496
|
+
'CMT': /^[CMT](?=\[)/,
|
497
|
+
'[(...)]': function _(input) {
|
498
|
+
return mhchemParser.patterns.findObserveGroups(input, "[", "", "", "]");
|
499
|
+
},
|
500
|
+
'1st-level escape': /^(&|\\\\|\\hline)\s*/,
|
501
|
+
'\\,': /^(?:\\[,\ ;:])/,
|
502
|
+
// \\x - but output no space before
|
503
|
+
'\\x{}{}': function x(input) {
|
504
|
+
return mhchemParser.patterns.findObserveGroups(input, "", /^\\[a-zA-Z]+\{/, "}", "", "", "{", "}", "", true);
|
505
|
+
},
|
506
|
+
'\\x{}': function x(input) {
|
507
|
+
return mhchemParser.patterns.findObserveGroups(input, "", /^\\[a-zA-Z]+\{/, "}", "");
|
508
|
+
},
|
509
|
+
'\\ca': /^\\ca(?:\s+|(?![a-zA-Z]))/,
|
510
|
+
'\\x': /^(?:\\[a-zA-Z]+\s*|\\[_&{}%])/,
|
511
|
+
'orbital': /^(?:[0-9]{1,2}[spdfgh]|[0-9]{0,2}sp)(?=$|[^a-zA-Z])/,
|
512
|
+
// only those with numbers in front, because the others will be formatted correctly anyway
|
513
|
+
'others': /^[\/~|]/,
|
514
|
+
'\\frac{(...)}': function frac(input) {
|
515
|
+
return mhchemParser.patterns.findObserveGroups(input, "\\frac{", "", "", "}", "{", "", "", "}");
|
516
|
+
},
|
517
|
+
'\\overset{(...)}': function overset(input) {
|
518
|
+
return mhchemParser.patterns.findObserveGroups(input, "\\overset{", "", "", "}", "{", "", "", "}");
|
519
|
+
},
|
520
|
+
"\\underset{(...)}": function underset(input) {
|
521
|
+
return mhchemParser.patterns.findObserveGroups(input, "\\underset{", "", "", "}", "{", "", "", "}");
|
522
|
+
},
|
523
|
+
"\\underbrace{(...)}": function underbrace(input) {
|
524
|
+
return mhchemParser.patterns.findObserveGroups(input, "\\underbrace{", "", "", "}_", "{", "", "", "}");
|
525
|
+
},
|
526
|
+
'\\color{(...)}0': function color0(input) {
|
527
|
+
return mhchemParser.patterns.findObserveGroups(input, "\\color{", "", "", "}");
|
528
|
+
},
|
529
|
+
'\\color{(...)}{(...)}1': function color1(input) {
|
530
|
+
return mhchemParser.patterns.findObserveGroups(input, "\\color{", "", "", "}", "{", "", "", "}");
|
531
|
+
},
|
532
|
+
'\\color(...){(...)}2': function color2(input) {
|
533
|
+
return mhchemParser.patterns.findObserveGroups(input, "\\color", "\\", "", /^(?=\{)/, "{", "", "", "}");
|
534
|
+
},
|
535
|
+
'\\ce{(...)}': function ce(input) {
|
536
|
+
return mhchemParser.patterns.findObserveGroups(input, "\\ce{", "", "", "}");
|
537
|
+
},
|
538
|
+
'oxidation$': /^(?:[+-][IVX]+|\\pm\s*0|\$\\pm\$\s*0)$/,
|
539
|
+
'd-oxidation$': /^(?:[+-]?\s?[IVX]+|\\pm\s*0|\$\\pm\$\s*0)$/,
|
540
|
+
// 0 could be oxidation or charge
|
541
|
+
'roman numeral': /^[IVX]+/,
|
542
|
+
'1/2$': /^[+\-]?(?:[0-9]+|\$[a-z]\$|[a-z])\/[0-9]+(?:\$[a-z]\$|[a-z])?$/,
|
543
|
+
'amount': function amount(input) {
|
544
|
+
var match; // e.g. 2, 0.5, 1/2, -2, n/2, +; $a$ could be added later in parsing
|
545
|
+
|
546
|
+
match = input.match(/^(?:(?:(?:\([+\-]?[0-9]+\/[0-9]+\)|[+\-]?(?:[0-9]+|\$[a-z]\$|[a-z])\/[0-9]+|[+\-]?[0-9]+[.,][0-9]+|[+\-]?\.[0-9]+|[+\-]?[0-9]+)(?:[a-z](?=\s*[A-Z]))?)|[+\-]?[a-z](?=\s*[A-Z])|\+(?!\s))/);
|
547
|
+
|
548
|
+
if (match) {
|
549
|
+
return {
|
550
|
+
match_: match[0],
|
551
|
+
remainder: input.substr(match[0].length)
|
552
|
+
};
|
553
|
+
}
|
554
|
+
|
555
|
+
var a = mhchemParser.patterns.findObserveGroups(input, "", "$", "$", "");
|
556
|
+
|
557
|
+
if (a) {
|
558
|
+
// e.g. $2n-1$, $-$
|
559
|
+
match = a.match_.match(/^\$(?:\(?[+\-]?(?:[0-9]*[a-z]?[+\-])?[0-9]*[a-z](?:[+\-][0-9]*[a-z]?)?\)?|\+|-)\$$/);
|
560
|
+
|
561
|
+
if (match) {
|
562
|
+
return {
|
563
|
+
match_: match[0],
|
564
|
+
remainder: input.substr(match[0].length)
|
565
|
+
};
|
566
|
+
}
|
567
|
+
}
|
568
|
+
|
569
|
+
return null;
|
570
|
+
},
|
571
|
+
'amount2': function amount2(input) {
|
572
|
+
return this['amount'](input);
|
573
|
+
},
|
574
|
+
'(KV letters),': /^(?:[A-Z][a-z]{0,2}|i)(?=,)/,
|
575
|
+
'formula$': function formula$(input) {
|
576
|
+
if (input.match(/^\([a-z]+\)$/)) {
|
577
|
+
return null;
|
578
|
+
} // state of aggregation = no formula
|
579
|
+
|
580
|
+
|
581
|
+
var match = input.match(/^(?:[a-z]|(?:[0-9\ \+\-\,\.\(\)]+[a-z])+[0-9\ \+\-\,\.\(\)]*|(?:[a-z][0-9\ \+\-\,\.\(\)]+)+[a-z]?)$/);
|
582
|
+
|
583
|
+
if (match) {
|
584
|
+
return {
|
585
|
+
match_: match[0],
|
586
|
+
remainder: input.substr(match[0].length)
|
587
|
+
};
|
588
|
+
}
|
589
|
+
|
590
|
+
return null;
|
591
|
+
},
|
592
|
+
'uprightEntities': /^(?:pH|pOH|pC|pK|iPr|iBu)(?=$|[^a-zA-Z])/,
|
593
|
+
'/': /^\s*(\/)\s*/,
|
594
|
+
'//': /^\s*(\/\/)\s*/,
|
595
|
+
'*': /^\s*[*.]\s*/
|
596
|
+
},
|
597
|
+
findObserveGroups: function findObserveGroups(input, begExcl, begIncl, endIncl, endExcl, beg2Excl, beg2Incl, end2Incl, end2Excl, combine) {
|
598
|
+
/** @type {{(input: string, pattern: string | RegExp): string | string[] | null;}} */
|
599
|
+
var _match = function _match(input, pattern) {
|
600
|
+
if (typeof pattern === "string") {
|
601
|
+
if (input.indexOf(pattern) !== 0) {
|
602
|
+
return null;
|
603
|
+
}
|
604
|
+
|
605
|
+
return pattern;
|
606
|
+
} else {
|
607
|
+
var match = input.match(pattern);
|
608
|
+
|
609
|
+
if (!match) {
|
610
|
+
return null;
|
611
|
+
}
|
612
|
+
|
613
|
+
return match[0];
|
614
|
+
}
|
615
|
+
};
|
616
|
+
/** @type {{(input: string, i: number, endChars: string | RegExp): {endMatchBegin: number, endMatchEnd: number} | null;}} */
|
617
|
+
|
618
|
+
|
619
|
+
var _findObserveGroups = function _findObserveGroups(input, i, endChars) {
|
620
|
+
var braces = 0;
|
621
|
+
|
622
|
+
while (i < input.length) {
|
623
|
+
var a = input.charAt(i);
|
624
|
+
|
625
|
+
var match = _match(input.substr(i), endChars);
|
626
|
+
|
627
|
+
if (match !== null && braces === 0) {
|
628
|
+
return {
|
629
|
+
endMatchBegin: i,
|
630
|
+
endMatchEnd: i + match.length
|
631
|
+
};
|
632
|
+
} else if (a === "{") {
|
633
|
+
braces++;
|
634
|
+
} else if (a === "}") {
|
635
|
+
if (braces === 0) {
|
636
|
+
throw ["ExtraCloseMissingOpen", "Extra close brace or missing open brace"];
|
637
|
+
} else {
|
638
|
+
braces--;
|
639
|
+
}
|
640
|
+
}
|
641
|
+
|
642
|
+
i++;
|
643
|
+
}
|
644
|
+
|
645
|
+
if (braces > 0) {
|
646
|
+
return null;
|
647
|
+
}
|
648
|
+
|
649
|
+
return null;
|
650
|
+
};
|
651
|
+
|
652
|
+
var match = _match(input, begExcl);
|
653
|
+
|
654
|
+
if (match === null) {
|
655
|
+
return null;
|
656
|
+
}
|
657
|
+
|
658
|
+
input = input.substr(match.length);
|
659
|
+
match = _match(input, begIncl);
|
660
|
+
|
661
|
+
if (match === null) {
|
662
|
+
return null;
|
663
|
+
}
|
664
|
+
|
665
|
+
var e = _findObserveGroups(input, match.length, endIncl || endExcl);
|
666
|
+
|
667
|
+
if (e === null) {
|
668
|
+
return null;
|
669
|
+
}
|
670
|
+
|
671
|
+
var match1 = input.substring(0, endIncl ? e.endMatchEnd : e.endMatchBegin);
|
672
|
+
|
673
|
+
if (!(beg2Excl || beg2Incl)) {
|
674
|
+
return {
|
675
|
+
match_: match1,
|
676
|
+
remainder: input.substr(e.endMatchEnd)
|
677
|
+
};
|
678
|
+
} else {
|
679
|
+
var group2 = this.findObserveGroups(input.substr(e.endMatchEnd), beg2Excl, beg2Incl, end2Incl, end2Excl);
|
680
|
+
|
681
|
+
if (group2 === null) {
|
682
|
+
return null;
|
683
|
+
}
|
684
|
+
/** @type {string[]} */
|
685
|
+
|
686
|
+
|
687
|
+
var matchRet = [match1, group2.match_];
|
688
|
+
return {
|
689
|
+
match_: combine ? matchRet.join("") : matchRet,
|
690
|
+
remainder: group2.remainder
|
691
|
+
};
|
692
|
+
}
|
693
|
+
},
|
694
|
+
//
|
695
|
+
// Matching function
|
696
|
+
// e.g. match("a", input) will look for the regexp called "a" and see if it matches
|
697
|
+
// returns null or {match_:"a", remainder:"bc"}
|
698
|
+
//
|
699
|
+
match_: function match_(m, input) {
|
700
|
+
var pattern = mhchemParser.patterns.patterns[m];
|
701
|
+
|
702
|
+
if (pattern === undefined) {
|
703
|
+
throw ["MhchemBugP", "mhchem bug P. Please report. (" + m + ")"]; // Trying to use non-existing pattern
|
704
|
+
} else if (typeof pattern === "function") {
|
705
|
+
return mhchemParser.patterns.patterns[m](input); // cannot use cached var pattern here, because some pattern functions need this===mhchemParser
|
706
|
+
} else {
|
707
|
+
// RegExp
|
708
|
+
var match = input.match(pattern);
|
709
|
+
|
710
|
+
if (match) {
|
711
|
+
var mm;
|
712
|
+
|
713
|
+
if (match[2]) {
|
714
|
+
mm = [match[1], match[2]];
|
715
|
+
} else if (match[1]) {
|
716
|
+
mm = match[1];
|
717
|
+
} else {
|
718
|
+
mm = match[0];
|
719
|
+
}
|
720
|
+
|
721
|
+
return {
|
722
|
+
match_: mm,
|
723
|
+
remainder: input.substr(match[0].length)
|
724
|
+
};
|
725
|
+
}
|
726
|
+
|
727
|
+
return null;
|
728
|
+
}
|
729
|
+
}
|
730
|
+
},
|
731
|
+
//
|
732
|
+
// Generic state machine actions
|
733
|
+
//
|
734
|
+
actions: {
|
735
|
+
'a=': function a(buffer, m) {
|
736
|
+
buffer.a = (buffer.a || "") + m;
|
737
|
+
},
|
738
|
+
'b=': function b(buffer, m) {
|
739
|
+
buffer.b = (buffer.b || "") + m;
|
740
|
+
},
|
741
|
+
'p=': function p(buffer, m) {
|
742
|
+
buffer.p = (buffer.p || "") + m;
|
743
|
+
},
|
744
|
+
'o=': function o(buffer, m) {
|
745
|
+
buffer.o = (buffer.o || "") + m;
|
746
|
+
},
|
747
|
+
'q=': function q(buffer, m) {
|
748
|
+
buffer.q = (buffer.q || "") + m;
|
749
|
+
},
|
750
|
+
'd=': function d(buffer, m) {
|
751
|
+
buffer.d = (buffer.d || "") + m;
|
752
|
+
},
|
753
|
+
'rm=': function rm(buffer, m) {
|
754
|
+
buffer.rm = (buffer.rm || "") + m;
|
755
|
+
},
|
756
|
+
'text=': function text(buffer, m) {
|
757
|
+
buffer.text_ = (buffer.text_ || "") + m;
|
758
|
+
},
|
759
|
+
'insert': function insert(buffer, m, a) {
|
760
|
+
return {
|
761
|
+
type_: a
|
762
|
+
};
|
763
|
+
},
|
764
|
+
'insert+p1': function insertP1(buffer, m, a) {
|
765
|
+
return {
|
766
|
+
type_: a,
|
767
|
+
p1: m
|
768
|
+
};
|
769
|
+
},
|
770
|
+
'insert+p1+p2': function insertP1P2(buffer, m, a) {
|
771
|
+
return {
|
772
|
+
type_: a,
|
773
|
+
p1: m[0],
|
774
|
+
p2: m[1]
|
775
|
+
};
|
776
|
+
},
|
777
|
+
'copy': function copy(buffer, m) {
|
778
|
+
return m;
|
779
|
+
},
|
780
|
+
'rm': function rm(buffer, m) {
|
781
|
+
return {
|
782
|
+
type_: 'rm',
|
783
|
+
p1: m || ""
|
784
|
+
};
|
785
|
+
},
|
786
|
+
'text': function text(buffer, m) {
|
787
|
+
return mhchemParser.go(m, 'text');
|
788
|
+
},
|
789
|
+
'{text}': function text(buffer, m) {
|
790
|
+
var ret = ["{"];
|
791
|
+
mhchemParser.concatArray(ret, mhchemParser.go(m, 'text'));
|
792
|
+
ret.push("}");
|
793
|
+
return ret;
|
794
|
+
},
|
795
|
+
'tex-math': function texMath(buffer, m) {
|
796
|
+
return mhchemParser.go(m, 'tex-math');
|
797
|
+
},
|
798
|
+
'tex-math tight': function texMathTight(buffer, m) {
|
799
|
+
return mhchemParser.go(m, 'tex-math tight');
|
800
|
+
},
|
801
|
+
'bond': function bond(buffer, m, k) {
|
802
|
+
return {
|
803
|
+
type_: 'bond',
|
804
|
+
kind_: k || m
|
805
|
+
};
|
806
|
+
},
|
807
|
+
'color0-output': function color0Output(buffer, m) {
|
808
|
+
return {
|
809
|
+
type_: 'color0',
|
810
|
+
color: m[0]
|
811
|
+
};
|
812
|
+
},
|
813
|
+
'ce': function ce(buffer, m) {
|
814
|
+
return mhchemParser.go(m);
|
815
|
+
},
|
816
|
+
'1/2': function _(buffer, m) {
|
817
|
+
/** @type {ParserOutput[]} */
|
818
|
+
var ret = [];
|
819
|
+
|
820
|
+
if (m.match(/^[+\-]/)) {
|
821
|
+
ret.push(m.substr(0, 1));
|
822
|
+
m = m.substr(1);
|
823
|
+
}
|
824
|
+
|
825
|
+
var n = m.match(/^([0-9]+|\$[a-z]\$|[a-z])\/([0-9]+)(\$[a-z]\$|[a-z])?$/);
|
826
|
+
n[1] = n[1].replace(/\$/g, "");
|
827
|
+
ret.push({
|
828
|
+
type_: 'frac',
|
829
|
+
p1: n[1],
|
830
|
+
p2: n[2]
|
831
|
+
});
|
832
|
+
|
833
|
+
if (n[3]) {
|
834
|
+
n[3] = n[3].replace(/\$/g, "");
|
835
|
+
ret.push({
|
836
|
+
type_: 'tex-math',
|
837
|
+
p1: n[3]
|
838
|
+
});
|
839
|
+
}
|
840
|
+
|
841
|
+
return ret;
|
842
|
+
},
|
843
|
+
'9,9': function _(buffer, m) {
|
844
|
+
return mhchemParser.go(m, '9,9');
|
845
|
+
}
|
846
|
+
},
|
847
|
+
//
|
848
|
+
// createTransitions
|
849
|
+
// convert { 'letter': { 'state': { action_: 'output' } } } to { 'state' => [ { pattern: 'letter', task: { action_: [{type_: 'output'}] } } ] }
|
850
|
+
// with expansion of 'a|b' to 'a' and 'b' (at 2 places)
|
851
|
+
//
|
852
|
+
createTransitions: function createTransitions(o) {
|
853
|
+
var pattern, state;
|
854
|
+
/** @type {string[]} */
|
855
|
+
|
856
|
+
var stateArray;
|
857
|
+
var i; //
|
858
|
+
// 1. Collect all states
|
859
|
+
//
|
860
|
+
|
861
|
+
/** @type {Transitions} */
|
862
|
+
|
863
|
+
var transitions = {};
|
864
|
+
|
865
|
+
for (pattern in o) {
|
866
|
+
for (state in o[pattern]) {
|
867
|
+
stateArray = state.split("|");
|
868
|
+
o[pattern][state].stateArray = stateArray;
|
869
|
+
|
870
|
+
for (i = 0; i < stateArray.length; i++) {
|
871
|
+
transitions[stateArray[i]] = [];
|
872
|
+
}
|
873
|
+
}
|
874
|
+
} //
|
875
|
+
// 2. Fill states
|
876
|
+
//
|
877
|
+
|
878
|
+
|
879
|
+
for (pattern in o) {
|
880
|
+
for (state in o[pattern]) {
|
881
|
+
stateArray = o[pattern][state].stateArray || [];
|
882
|
+
|
883
|
+
for (i = 0; i < stateArray.length; i++) {
|
884
|
+
//
|
885
|
+
// 2a. Normalize actions into array: 'text=' ==> [{type_:'text='}]
|
886
|
+
// (Note to myself: Resolving the function here would be problematic. It would need .bind (for *this*) and currying (for *option*).)
|
887
|
+
//
|
888
|
+
|
889
|
+
/** @type {any} */
|
890
|
+
var p = o[pattern][state];
|
891
|
+
|
892
|
+
if (p.action_) {
|
893
|
+
p.action_ = [].concat(p.action_);
|
894
|
+
|
895
|
+
for (var k = 0; k < p.action_.length; k++) {
|
896
|
+
if (typeof p.action_[k] === "string") {
|
897
|
+
p.action_[k] = {
|
898
|
+
type_: p.action_[k]
|
899
|
+
};
|
900
|
+
}
|
901
|
+
}
|
902
|
+
} else {
|
903
|
+
p.action_ = [];
|
904
|
+
} //
|
905
|
+
// 2.b Multi-insert
|
906
|
+
//
|
907
|
+
|
908
|
+
|
909
|
+
var patternArray = pattern.split("|");
|
910
|
+
|
911
|
+
for (var j = 0; j < patternArray.length; j++) {
|
912
|
+
if (stateArray[i] === '*') {
|
913
|
+
// insert into all
|
914
|
+
for (var t in transitions) {
|
915
|
+
transitions[t].push({
|
916
|
+
pattern: patternArray[j],
|
917
|
+
task: p
|
918
|
+
});
|
919
|
+
}
|
920
|
+
} else {
|
921
|
+
transitions[stateArray[i]].push({
|
922
|
+
pattern: patternArray[j],
|
923
|
+
task: p
|
924
|
+
});
|
925
|
+
}
|
926
|
+
}
|
927
|
+
}
|
928
|
+
}
|
929
|
+
}
|
930
|
+
|
931
|
+
return transitions;
|
932
|
+
},
|
933
|
+
stateMachines: {}
|
934
|
+
}; //
|
935
|
+
// Definition of state machines
|
936
|
+
//
|
937
|
+
|
938
|
+
mhchemParser.stateMachines = {
|
939
|
+
//
|
940
|
+
// \ce state machines
|
941
|
+
//
|
942
|
+
//#region ce
|
943
|
+
'ce': {
|
944
|
+
// main parser
|
945
|
+
transitions: mhchemParser.createTransitions({
|
946
|
+
'empty': {
|
947
|
+
'*': {
|
948
|
+
action_: 'output'
|
949
|
+
}
|
950
|
+
},
|
951
|
+
'else': {
|
952
|
+
'0|1|2': {
|
953
|
+
action_: 'beginsWithBond=false',
|
954
|
+
revisit: true,
|
955
|
+
toContinue: true
|
956
|
+
}
|
957
|
+
},
|
958
|
+
'oxidation$': {
|
959
|
+
'0': {
|
960
|
+
action_: 'oxidation-output'
|
961
|
+
}
|
962
|
+
},
|
963
|
+
'CMT': {
|
964
|
+
'r': {
|
965
|
+
action_: 'rdt=',
|
966
|
+
nextState: 'rt'
|
967
|
+
},
|
968
|
+
'rd': {
|
969
|
+
action_: 'rqt=',
|
970
|
+
nextState: 'rdt'
|
971
|
+
}
|
972
|
+
},
|
973
|
+
'arrowUpDown': {
|
974
|
+
'0|1|2|as': {
|
975
|
+
action_: ['sb=false', 'output', 'operator'],
|
976
|
+
nextState: '1'
|
977
|
+
}
|
978
|
+
},
|
979
|
+
'uprightEntities': {
|
980
|
+
'0|1|2': {
|
981
|
+
action_: ['o=', 'output'],
|
982
|
+
nextState: '1'
|
983
|
+
}
|
984
|
+
},
|
985
|
+
'orbital': {
|
986
|
+
'0|1|2|3': {
|
987
|
+
action_: 'o=',
|
988
|
+
nextState: 'o'
|
989
|
+
}
|
990
|
+
},
|
991
|
+
'->': {
|
992
|
+
'0|1|2|3': {
|
993
|
+
action_: 'r=',
|
994
|
+
nextState: 'r'
|
995
|
+
},
|
996
|
+
'a|as': {
|
997
|
+
action_: ['output', 'r='],
|
998
|
+
nextState: 'r'
|
999
|
+
},
|
1000
|
+
'*': {
|
1001
|
+
action_: ['output', 'r='],
|
1002
|
+
nextState: 'r'
|
1003
|
+
}
|
1004
|
+
},
|
1005
|
+
'+': {
|
1006
|
+
'o': {
|
1007
|
+
action_: 'd= kv',
|
1008
|
+
nextState: 'd'
|
1009
|
+
},
|
1010
|
+
'd|D': {
|
1011
|
+
action_: 'd=',
|
1012
|
+
nextState: 'd'
|
1013
|
+
},
|
1014
|
+
'q': {
|
1015
|
+
action_: 'd=',
|
1016
|
+
nextState: 'qd'
|
1017
|
+
},
|
1018
|
+
'qd|qD': {
|
1019
|
+
action_: 'd=',
|
1020
|
+
nextState: 'qd'
|
1021
|
+
},
|
1022
|
+
'dq': {
|
1023
|
+
action_: ['output', 'd='],
|
1024
|
+
nextState: 'd'
|
1025
|
+
},
|
1026
|
+
'3': {
|
1027
|
+
action_: ['sb=false', 'output', 'operator'],
|
1028
|
+
nextState: '0'
|
1029
|
+
}
|
1030
|
+
},
|
1031
|
+
'amount': {
|
1032
|
+
'0|2': {
|
1033
|
+
action_: 'a=',
|
1034
|
+
nextState: 'a'
|
1035
|
+
}
|
1036
|
+
},
|
1037
|
+
'pm-operator': {
|
1038
|
+
'0|1|2|a|as': {
|
1039
|
+
action_: ['sb=false', 'output', {
|
1040
|
+
type_: 'operator',
|
1041
|
+
option: '\\pm'
|
1042
|
+
}],
|
1043
|
+
nextState: '0'
|
1044
|
+
}
|
1045
|
+
},
|
1046
|
+
'operator': {
|
1047
|
+
'0|1|2|a|as': {
|
1048
|
+
action_: ['sb=false', 'output', 'operator'],
|
1049
|
+
nextState: '0'
|
1050
|
+
}
|
1051
|
+
},
|
1052
|
+
'-$': {
|
1053
|
+
'o|q': {
|
1054
|
+
action_: ['charge or bond', 'output'],
|
1055
|
+
nextState: 'qd'
|
1056
|
+
},
|
1057
|
+
'd': {
|
1058
|
+
action_: 'd=',
|
1059
|
+
nextState: 'd'
|
1060
|
+
},
|
1061
|
+
'D': {
|
1062
|
+
action_: ['output', {
|
1063
|
+
type_: 'bond',
|
1064
|
+
option: "-"
|
1065
|
+
}],
|
1066
|
+
nextState: '3'
|
1067
|
+
},
|
1068
|
+
'q': {
|
1069
|
+
action_: 'd=',
|
1070
|
+
nextState: 'qd'
|
1071
|
+
},
|
1072
|
+
'qd': {
|
1073
|
+
action_: 'd=',
|
1074
|
+
nextState: 'qd'
|
1075
|
+
},
|
1076
|
+
'qD|dq': {
|
1077
|
+
action_: ['output', {
|
1078
|
+
type_: 'bond',
|
1079
|
+
option: "-"
|
1080
|
+
}],
|
1081
|
+
nextState: '3'
|
1082
|
+
}
|
1083
|
+
},
|
1084
|
+
'-9': {
|
1085
|
+
'3|o': {
|
1086
|
+
action_: ['output', {
|
1087
|
+
type_: 'insert',
|
1088
|
+
option: 'hyphen'
|
1089
|
+
}],
|
1090
|
+
nextState: '3'
|
1091
|
+
}
|
1092
|
+
},
|
1093
|
+
'- orbital overlap': {
|
1094
|
+
'o': {
|
1095
|
+
action_: ['output', {
|
1096
|
+
type_: 'insert',
|
1097
|
+
option: 'hyphen'
|
1098
|
+
}],
|
1099
|
+
nextState: '2'
|
1100
|
+
},
|
1101
|
+
'd': {
|
1102
|
+
action_: ['output', {
|
1103
|
+
type_: 'insert',
|
1104
|
+
option: 'hyphen'
|
1105
|
+
}],
|
1106
|
+
nextState: '2'
|
1107
|
+
}
|
1108
|
+
},
|
1109
|
+
'-': {
|
1110
|
+
'0|1|2': {
|
1111
|
+
action_: [{
|
1112
|
+
type_: 'output',
|
1113
|
+
option: 1
|
1114
|
+
}, 'beginsWithBond=true', {
|
1115
|
+
type_: 'bond',
|
1116
|
+
option: "-"
|
1117
|
+
}],
|
1118
|
+
nextState: '3'
|
1119
|
+
},
|
1120
|
+
'3': {
|
1121
|
+
action_: {
|
1122
|
+
type_: 'bond',
|
1123
|
+
option: "-"
|
1124
|
+
}
|
1125
|
+
},
|
1126
|
+
'a': {
|
1127
|
+
action_: ['output', {
|
1128
|
+
type_: 'insert',
|
1129
|
+
option: 'hyphen'
|
1130
|
+
}],
|
1131
|
+
nextState: '2'
|
1132
|
+
},
|
1133
|
+
'as': {
|
1134
|
+
action_: [{
|
1135
|
+
type_: 'output',
|
1136
|
+
option: 2
|
1137
|
+
}, {
|
1138
|
+
type_: 'bond',
|
1139
|
+
option: "-"
|
1140
|
+
}],
|
1141
|
+
nextState: '3'
|
1142
|
+
},
|
1143
|
+
'b': {
|
1144
|
+
action_: 'b='
|
1145
|
+
},
|
1146
|
+
'o': {
|
1147
|
+
action_: {
|
1148
|
+
type_: '- after o/d',
|
1149
|
+
option: false
|
1150
|
+
},
|
1151
|
+
nextState: '2'
|
1152
|
+
},
|
1153
|
+
'q': {
|
1154
|
+
action_: {
|
1155
|
+
type_: '- after o/d',
|
1156
|
+
option: false
|
1157
|
+
},
|
1158
|
+
nextState: '2'
|
1159
|
+
},
|
1160
|
+
'd|qd|dq': {
|
1161
|
+
action_: {
|
1162
|
+
type_: '- after o/d',
|
1163
|
+
option: true
|
1164
|
+
},
|
1165
|
+
nextState: '2'
|
1166
|
+
},
|
1167
|
+
'D|qD|p': {
|
1168
|
+
action_: ['output', {
|
1169
|
+
type_: 'bond',
|
1170
|
+
option: "-"
|
1171
|
+
}],
|
1172
|
+
nextState: '3'
|
1173
|
+
}
|
1174
|
+
},
|
1175
|
+
'amount2': {
|
1176
|
+
'1|3': {
|
1177
|
+
action_: 'a=',
|
1178
|
+
nextState: 'a'
|
1179
|
+
}
|
1180
|
+
},
|
1181
|
+
'letters': {
|
1182
|
+
'0|1|2|3|a|as|b|p|bp|o': {
|
1183
|
+
action_: 'o=',
|
1184
|
+
nextState: 'o'
|
1185
|
+
},
|
1186
|
+
'q|dq': {
|
1187
|
+
action_: ['output', 'o='],
|
1188
|
+
nextState: 'o'
|
1189
|
+
},
|
1190
|
+
'd|D|qd|qD': {
|
1191
|
+
action_: 'o after d',
|
1192
|
+
nextState: 'o'
|
1193
|
+
}
|
1194
|
+
},
|
1195
|
+
'digits': {
|
1196
|
+
'o': {
|
1197
|
+
action_: 'q=',
|
1198
|
+
nextState: 'q'
|
1199
|
+
},
|
1200
|
+
'd|D': {
|
1201
|
+
action_: 'q=',
|
1202
|
+
nextState: 'dq'
|
1203
|
+
},
|
1204
|
+
'q': {
|
1205
|
+
action_: ['output', 'o='],
|
1206
|
+
nextState: 'o'
|
1207
|
+
},
|
1208
|
+
'a': {
|
1209
|
+
action_: 'o=',
|
1210
|
+
nextState: 'o'
|
1211
|
+
}
|
1212
|
+
},
|
1213
|
+
'space A': {
|
1214
|
+
'b|p|bp': {}
|
1215
|
+
},
|
1216
|
+
'space': {
|
1217
|
+
'a': {
|
1218
|
+
nextState: 'as'
|
1219
|
+
},
|
1220
|
+
'0': {
|
1221
|
+
action_: 'sb=false'
|
1222
|
+
},
|
1223
|
+
'1|2': {
|
1224
|
+
action_: 'sb=true'
|
1225
|
+
},
|
1226
|
+
'r|rt|rd|rdt|rdq': {
|
1227
|
+
action_: 'output',
|
1228
|
+
nextState: '0'
|
1229
|
+
},
|
1230
|
+
'*': {
|
1231
|
+
action_: ['output', 'sb=true'],
|
1232
|
+
nextState: '1'
|
1233
|
+
}
|
1234
|
+
},
|
1235
|
+
'1st-level escape': {
|
1236
|
+
'1|2': {
|
1237
|
+
action_: ['output', {
|
1238
|
+
type_: 'insert+p1',
|
1239
|
+
option: '1st-level escape'
|
1240
|
+
}]
|
1241
|
+
},
|
1242
|
+
'*': {
|
1243
|
+
action_: ['output', {
|
1244
|
+
type_: 'insert+p1',
|
1245
|
+
option: '1st-level escape'
|
1246
|
+
}],
|
1247
|
+
nextState: '0'
|
1248
|
+
}
|
1249
|
+
},
|
1250
|
+
'[(...)]': {
|
1251
|
+
'r|rt': {
|
1252
|
+
action_: 'rd=',
|
1253
|
+
nextState: 'rd'
|
1254
|
+
},
|
1255
|
+
'rd|rdt': {
|
1256
|
+
action_: 'rq=',
|
1257
|
+
nextState: 'rdq'
|
1258
|
+
}
|
1259
|
+
},
|
1260
|
+
'...': {
|
1261
|
+
'o|d|D|dq|qd|qD': {
|
1262
|
+
action_: ['output', {
|
1263
|
+
type_: 'bond',
|
1264
|
+
option: "..."
|
1265
|
+
}],
|
1266
|
+
nextState: '3'
|
1267
|
+
},
|
1268
|
+
'*': {
|
1269
|
+
action_: [{
|
1270
|
+
type_: 'output',
|
1271
|
+
option: 1
|
1272
|
+
}, {
|
1273
|
+
type_: 'insert',
|
1274
|
+
option: 'ellipsis'
|
1275
|
+
}],
|
1276
|
+
nextState: '1'
|
1277
|
+
}
|
1278
|
+
},
|
1279
|
+
'. |* ': {
|
1280
|
+
'*': {
|
1281
|
+
action_: ['output', {
|
1282
|
+
type_: 'insert',
|
1283
|
+
option: 'addition compound'
|
1284
|
+
}],
|
1285
|
+
nextState: '1'
|
1286
|
+
}
|
1287
|
+
},
|
1288
|
+
'state of aggregation $': {
|
1289
|
+
'*': {
|
1290
|
+
action_: ['output', 'state of aggregation'],
|
1291
|
+
nextState: '1'
|
1292
|
+
}
|
1293
|
+
},
|
1294
|
+
'{[(': {
|
1295
|
+
'a|as|o': {
|
1296
|
+
action_: ['o=', 'output', 'parenthesisLevel++'],
|
1297
|
+
nextState: '2'
|
1298
|
+
},
|
1299
|
+
'0|1|2|3': {
|
1300
|
+
action_: ['o=', 'output', 'parenthesisLevel++'],
|
1301
|
+
nextState: '2'
|
1302
|
+
},
|
1303
|
+
'*': {
|
1304
|
+
action_: ['output', 'o=', 'output', 'parenthesisLevel++'],
|
1305
|
+
nextState: '2'
|
1306
|
+
}
|
1307
|
+
},
|
1308
|
+
')]}': {
|
1309
|
+
'0|1|2|3|b|p|bp|o': {
|
1310
|
+
action_: ['o=', 'parenthesisLevel--'],
|
1311
|
+
nextState: 'o'
|
1312
|
+
},
|
1313
|
+
'a|as|d|D|q|qd|qD|dq': {
|
1314
|
+
action_: ['output', 'o=', 'parenthesisLevel--'],
|
1315
|
+
nextState: 'o'
|
1316
|
+
}
|
1317
|
+
},
|
1318
|
+
', ': {
|
1319
|
+
'*': {
|
1320
|
+
action_: ['output', 'comma'],
|
1321
|
+
nextState: '0'
|
1322
|
+
}
|
1323
|
+
},
|
1324
|
+
'^_': {
|
1325
|
+
// ^ and _ without a sensible argument
|
1326
|
+
'*': {}
|
1327
|
+
},
|
1328
|
+
'^{(...)}|^($...$)': {
|
1329
|
+
'0|1|2|as': {
|
1330
|
+
action_: 'b=',
|
1331
|
+
nextState: 'b'
|
1332
|
+
},
|
1333
|
+
'p': {
|
1334
|
+
action_: 'b=',
|
1335
|
+
nextState: 'bp'
|
1336
|
+
},
|
1337
|
+
'3|o': {
|
1338
|
+
action_: 'd= kv',
|
1339
|
+
nextState: 'D'
|
1340
|
+
},
|
1341
|
+
'q': {
|
1342
|
+
action_: 'd=',
|
1343
|
+
nextState: 'qD'
|
1344
|
+
},
|
1345
|
+
'd|D|qd|qD|dq': {
|
1346
|
+
action_: ['output', 'd='],
|
1347
|
+
nextState: 'D'
|
1348
|
+
}
|
1349
|
+
},
|
1350
|
+
'^a|^\\x{}{}|^\\x{}|^\\x|\'': {
|
1351
|
+
'0|1|2|as': {
|
1352
|
+
action_: 'b=',
|
1353
|
+
nextState: 'b'
|
1354
|
+
},
|
1355
|
+
'p': {
|
1356
|
+
action_: 'b=',
|
1357
|
+
nextState: 'bp'
|
1358
|
+
},
|
1359
|
+
'3|o': {
|
1360
|
+
action_: 'd= kv',
|
1361
|
+
nextState: 'd'
|
1362
|
+
},
|
1363
|
+
'q': {
|
1364
|
+
action_: 'd=',
|
1365
|
+
nextState: 'qd'
|
1366
|
+
},
|
1367
|
+
'd|qd|D|qD': {
|
1368
|
+
action_: 'd='
|
1369
|
+
},
|
1370
|
+
'dq': {
|
1371
|
+
action_: ['output', 'd='],
|
1372
|
+
nextState: 'd'
|
1373
|
+
}
|
1374
|
+
},
|
1375
|
+
'_{(state of aggregation)}$': {
|
1376
|
+
'd|D|q|qd|qD|dq': {
|
1377
|
+
action_: ['output', 'q='],
|
1378
|
+
nextState: 'q'
|
1379
|
+
}
|
1380
|
+
},
|
1381
|
+
'_{(...)}|_($...$)|_9|_\\x{}{}|_\\x{}|_\\x': {
|
1382
|
+
'0|1|2|as': {
|
1383
|
+
action_: 'p=',
|
1384
|
+
nextState: 'p'
|
1385
|
+
},
|
1386
|
+
'b': {
|
1387
|
+
action_: 'p=',
|
1388
|
+
nextState: 'bp'
|
1389
|
+
},
|
1390
|
+
'3|o': {
|
1391
|
+
action_: 'q=',
|
1392
|
+
nextState: 'q'
|
1393
|
+
},
|
1394
|
+
'd|D': {
|
1395
|
+
action_: 'q=',
|
1396
|
+
nextState: 'dq'
|
1397
|
+
},
|
1398
|
+
'q|qd|qD|dq': {
|
1399
|
+
action_: ['output', 'q='],
|
1400
|
+
nextState: 'q'
|
1401
|
+
}
|
1402
|
+
},
|
1403
|
+
'=<>': {
|
1404
|
+
'0|1|2|3|a|as|o|q|d|D|qd|qD|dq': {
|
1405
|
+
action_: [{
|
1406
|
+
type_: 'output',
|
1407
|
+
option: 2
|
1408
|
+
}, 'bond'],
|
1409
|
+
nextState: '3'
|
1410
|
+
}
|
1411
|
+
},
|
1412
|
+
'#': {
|
1413
|
+
'0|1|2|3|a|as|o': {
|
1414
|
+
action_: [{
|
1415
|
+
type_: 'output',
|
1416
|
+
option: 2
|
1417
|
+
}, {
|
1418
|
+
type_: 'bond',
|
1419
|
+
option: "#"
|
1420
|
+
}],
|
1421
|
+
nextState: '3'
|
1422
|
+
}
|
1423
|
+
},
|
1424
|
+
'{}': {
|
1425
|
+
'*': {
|
1426
|
+
action_: {
|
1427
|
+
type_: 'output',
|
1428
|
+
option: 1
|
1429
|
+
},
|
1430
|
+
nextState: '1'
|
1431
|
+
}
|
1432
|
+
},
|
1433
|
+
'{...}': {
|
1434
|
+
'0|1|2|3|a|as|b|p|bp': {
|
1435
|
+
action_: 'o=',
|
1436
|
+
nextState: 'o'
|
1437
|
+
},
|
1438
|
+
'o|d|D|q|qd|qD|dq': {
|
1439
|
+
action_: ['output', 'o='],
|
1440
|
+
nextState: 'o'
|
1441
|
+
}
|
1442
|
+
},
|
1443
|
+
'$...$': {
|
1444
|
+
'a': {
|
1445
|
+
action_: 'a='
|
1446
|
+
},
|
1447
|
+
// 2$n$
|
1448
|
+
'0|1|2|3|as|b|p|bp|o': {
|
1449
|
+
action_: 'o=',
|
1450
|
+
nextState: 'o'
|
1451
|
+
},
|
1452
|
+
// not 'amount'
|
1453
|
+
'as|o': {
|
1454
|
+
action_: 'o='
|
1455
|
+
},
|
1456
|
+
'q|d|D|qd|qD|dq': {
|
1457
|
+
action_: ['output', 'o='],
|
1458
|
+
nextState: 'o'
|
1459
|
+
}
|
1460
|
+
},
|
1461
|
+
'\\bond{(...)}': {
|
1462
|
+
'*': {
|
1463
|
+
action_: [{
|
1464
|
+
type_: 'output',
|
1465
|
+
option: 2
|
1466
|
+
}, 'bond'],
|
1467
|
+
nextState: "3"
|
1468
|
+
}
|
1469
|
+
},
|
1470
|
+
'\\frac{(...)}': {
|
1471
|
+
'*': {
|
1472
|
+
action_: [{
|
1473
|
+
type_: 'output',
|
1474
|
+
option: 1
|
1475
|
+
}, 'frac-output'],
|
1476
|
+
nextState: '3'
|
1477
|
+
}
|
1478
|
+
},
|
1479
|
+
'\\overset{(...)}': {
|
1480
|
+
'*': {
|
1481
|
+
action_: [{
|
1482
|
+
type_: 'output',
|
1483
|
+
option: 2
|
1484
|
+
}, 'overset-output'],
|
1485
|
+
nextState: '3'
|
1486
|
+
}
|
1487
|
+
},
|
1488
|
+
"\\underset{(...)}": {
|
1489
|
+
'*': {
|
1490
|
+
action_: [{
|
1491
|
+
type_: 'output',
|
1492
|
+
option: 2
|
1493
|
+
}, 'underset-output'],
|
1494
|
+
nextState: '3'
|
1495
|
+
}
|
1496
|
+
},
|
1497
|
+
"\\underbrace{(...)}": {
|
1498
|
+
'*': {
|
1499
|
+
action_: [{
|
1500
|
+
type_: 'output',
|
1501
|
+
option: 2
|
1502
|
+
}, 'underbrace-output'],
|
1503
|
+
nextState: '3'
|
1504
|
+
}
|
1505
|
+
},
|
1506
|
+
'\\color{(...)}{(...)}1|\\color(...){(...)}2': {
|
1507
|
+
'*': {
|
1508
|
+
action_: [{
|
1509
|
+
type_: 'output',
|
1510
|
+
option: 2
|
1511
|
+
}, 'color-output'],
|
1512
|
+
nextState: '3'
|
1513
|
+
}
|
1514
|
+
},
|
1515
|
+
'\\color{(...)}0': {
|
1516
|
+
'*': {
|
1517
|
+
action_: [{
|
1518
|
+
type_: 'output',
|
1519
|
+
option: 2
|
1520
|
+
}, 'color0-output']
|
1521
|
+
}
|
1522
|
+
},
|
1523
|
+
'\\ce{(...)}': {
|
1524
|
+
'*': {
|
1525
|
+
action_: [{
|
1526
|
+
type_: 'output',
|
1527
|
+
option: 2
|
1528
|
+
}, 'ce'],
|
1529
|
+
nextState: '3'
|
1530
|
+
}
|
1531
|
+
},
|
1532
|
+
'\\,': {
|
1533
|
+
'*': {
|
1534
|
+
action_: [{
|
1535
|
+
type_: 'output',
|
1536
|
+
option: 1
|
1537
|
+
}, 'copy'],
|
1538
|
+
nextState: '1'
|
1539
|
+
}
|
1540
|
+
},
|
1541
|
+
'\\x{}{}|\\x{}|\\x': {
|
1542
|
+
'0|1|2|3|a|as|b|p|bp|o|c0': {
|
1543
|
+
action_: ['o=', 'output'],
|
1544
|
+
nextState: '3'
|
1545
|
+
},
|
1546
|
+
'*': {
|
1547
|
+
action_: ['output', 'o=', 'output'],
|
1548
|
+
nextState: '3'
|
1549
|
+
}
|
1550
|
+
},
|
1551
|
+
'others': {
|
1552
|
+
'*': {
|
1553
|
+
action_: [{
|
1554
|
+
type_: 'output',
|
1555
|
+
option: 1
|
1556
|
+
}, 'copy'],
|
1557
|
+
nextState: '3'
|
1558
|
+
}
|
1559
|
+
},
|
1560
|
+
'else2': {
|
1561
|
+
'a': {
|
1562
|
+
action_: 'a to o',
|
1563
|
+
nextState: 'o',
|
1564
|
+
revisit: true
|
1565
|
+
},
|
1566
|
+
'as': {
|
1567
|
+
action_: ['output', 'sb=true'],
|
1568
|
+
nextState: '1',
|
1569
|
+
revisit: true
|
1570
|
+
},
|
1571
|
+
'r|rt|rd|rdt|rdq': {
|
1572
|
+
action_: ['output'],
|
1573
|
+
nextState: '0',
|
1574
|
+
revisit: true
|
1575
|
+
},
|
1576
|
+
'*': {
|
1577
|
+
action_: ['output', 'copy'],
|
1578
|
+
nextState: '3'
|
1579
|
+
}
|
1580
|
+
}
|
1581
|
+
}),
|
1582
|
+
actions: {
|
1583
|
+
'o after d': function oAfterD(buffer, m) {
|
1584
|
+
var ret;
|
1585
|
+
|
1586
|
+
if ((buffer.d || "").match(/^[0-9]+$/)) {
|
1587
|
+
var tmp = buffer.d;
|
1588
|
+
buffer.d = undefined;
|
1589
|
+
ret = this['output'](buffer);
|
1590
|
+
buffer.b = tmp;
|
1591
|
+
} else {
|
1592
|
+
ret = this['output'](buffer);
|
1593
|
+
}
|
1594
|
+
|
1595
|
+
mhchemParser.actions['o='](buffer, m);
|
1596
|
+
return ret;
|
1597
|
+
},
|
1598
|
+
'd= kv': function dKv(buffer, m) {
|
1599
|
+
buffer.d = m;
|
1600
|
+
buffer.dType = 'kv';
|
1601
|
+
},
|
1602
|
+
'charge or bond': function chargeOrBond(buffer, m) {
|
1603
|
+
if (buffer['beginsWithBond']) {
|
1604
|
+
/** @type {ParserOutput[]} */
|
1605
|
+
var ret = [];
|
1606
|
+
mhchemParser.concatArray(ret, this['output'](buffer));
|
1607
|
+
mhchemParser.concatArray(ret, mhchemParser.actions['bond'](buffer, m, "-"));
|
1608
|
+
return ret;
|
1609
|
+
} else {
|
1610
|
+
buffer.d = m;
|
1611
|
+
}
|
1612
|
+
},
|
1613
|
+
'- after o/d': function afterOD(buffer, m, isAfterD) {
|
1614
|
+
var c1 = mhchemParser.patterns.match_('orbital', buffer.o || "");
|
1615
|
+
var c2 = mhchemParser.patterns.match_('one lowercase greek letter $', buffer.o || "");
|
1616
|
+
var c3 = mhchemParser.patterns.match_('one lowercase latin letter $', buffer.o || "");
|
1617
|
+
var c4 = mhchemParser.patterns.match_('$one lowercase latin letter$ $', buffer.o || "");
|
1618
|
+
var hyphenFollows = m === "-" && (c1 && c1.remainder === "" || c2 || c3 || c4);
|
1619
|
+
|
1620
|
+
if (hyphenFollows && !buffer.a && !buffer.b && !buffer.p && !buffer.d && !buffer.q && !c1 && c3) {
|
1621
|
+
buffer.o = '$' + buffer.o + '$';
|
1622
|
+
}
|
1623
|
+
/** @type {ParserOutput[]} */
|
1624
|
+
|
1625
|
+
|
1626
|
+
var ret = [];
|
1627
|
+
|
1628
|
+
if (hyphenFollows) {
|
1629
|
+
mhchemParser.concatArray(ret, this['output'](buffer));
|
1630
|
+
ret.push({
|
1631
|
+
type_: 'hyphen'
|
1632
|
+
});
|
1633
|
+
} else {
|
1634
|
+
c1 = mhchemParser.patterns.match_('digits', buffer.d || "");
|
1635
|
+
|
1636
|
+
if (isAfterD && c1 && c1.remainder === '') {
|
1637
|
+
mhchemParser.concatArray(ret, mhchemParser.actions['d='](buffer, m));
|
1638
|
+
mhchemParser.concatArray(ret, this['output'](buffer));
|
1639
|
+
} else {
|
1640
|
+
mhchemParser.concatArray(ret, this['output'](buffer));
|
1641
|
+
mhchemParser.concatArray(ret, mhchemParser.actions['bond'](buffer, m, "-"));
|
1642
|
+
}
|
1643
|
+
}
|
1644
|
+
|
1645
|
+
return ret;
|
1646
|
+
},
|
1647
|
+
'a to o': function aToO(buffer) {
|
1648
|
+
buffer.o = buffer.a;
|
1649
|
+
buffer.a = undefined;
|
1650
|
+
},
|
1651
|
+
'sb=true': function sbTrue(buffer) {
|
1652
|
+
buffer.sb = true;
|
1653
|
+
},
|
1654
|
+
'sb=false': function sbFalse(buffer) {
|
1655
|
+
buffer.sb = false;
|
1656
|
+
},
|
1657
|
+
'beginsWithBond=true': function beginsWithBondTrue(buffer) {
|
1658
|
+
buffer['beginsWithBond'] = true;
|
1659
|
+
},
|
1660
|
+
'beginsWithBond=false': function beginsWithBondFalse(buffer) {
|
1661
|
+
buffer['beginsWithBond'] = false;
|
1662
|
+
},
|
1663
|
+
'parenthesisLevel++': function parenthesisLevel(buffer) {
|
1664
|
+
buffer['parenthesisLevel']++;
|
1665
|
+
},
|
1666
|
+
'parenthesisLevel--': function parenthesisLevel(buffer) {
|
1667
|
+
buffer['parenthesisLevel']--;
|
1668
|
+
},
|
1669
|
+
'state of aggregation': function stateOfAggregation(buffer, m) {
|
1670
|
+
return {
|
1671
|
+
type_: 'state of aggregation',
|
1672
|
+
p1: mhchemParser.go(m, 'o')
|
1673
|
+
};
|
1674
|
+
},
|
1675
|
+
'comma': function comma(buffer, m) {
|
1676
|
+
var a = m.replace(/\s*$/, '');
|
1677
|
+
var withSpace = a !== m;
|
1678
|
+
|
1679
|
+
if (withSpace && buffer['parenthesisLevel'] === 0) {
|
1680
|
+
return {
|
1681
|
+
type_: 'comma enumeration L',
|
1682
|
+
p1: a
|
1683
|
+
};
|
1684
|
+
} else {
|
1685
|
+
return {
|
1686
|
+
type_: 'comma enumeration M',
|
1687
|
+
p1: a
|
1688
|
+
};
|
1689
|
+
}
|
1690
|
+
},
|
1691
|
+
'output': function output(buffer, m, entityFollows) {
|
1692
|
+
// entityFollows:
|
1693
|
+
// undefined = if we have nothing else to output, also ignore the just read space (buffer.sb)
|
1694
|
+
// 1 = an entity follows, never omit the space if there was one just read before (can only apply to state 1)
|
1695
|
+
// 2 = 1 + the entity can have an amount, so output a\, instead of converting it to o (can only apply to states a|as)
|
1696
|
+
|
1697
|
+
/** @type {ParserOutput | ParserOutput[]} */
|
1698
|
+
var ret;
|
1699
|
+
|
1700
|
+
if (!buffer.r) {
|
1701
|
+
ret = [];
|
1702
|
+
|
1703
|
+
if (!buffer.a && !buffer.b && !buffer.p && !buffer.o && !buffer.q && !buffer.d && !entityFollows) {//ret = [];
|
1704
|
+
} else {
|
1705
|
+
if (buffer.sb) {
|
1706
|
+
ret.push({
|
1707
|
+
type_: 'entitySkip'
|
1708
|
+
});
|
1709
|
+
}
|
1710
|
+
|
1711
|
+
if (!buffer.o && !buffer.q && !buffer.d && !buffer.b && !buffer.p && entityFollows !== 2) {
|
1712
|
+
buffer.o = buffer.a;
|
1713
|
+
buffer.a = undefined;
|
1714
|
+
} else if (!buffer.o && !buffer.q && !buffer.d && (buffer.b || buffer.p)) {
|
1715
|
+
buffer.o = buffer.a;
|
1716
|
+
buffer.d = buffer.b;
|
1717
|
+
buffer.q = buffer.p;
|
1718
|
+
buffer.a = buffer.b = buffer.p = undefined;
|
1719
|
+
} else {
|
1720
|
+
if (buffer.o && buffer.dType === 'kv' && mhchemParser.patterns.match_('d-oxidation$', buffer.d || "")) {
|
1721
|
+
buffer.dType = 'oxidation';
|
1722
|
+
} else if (buffer.o && buffer.dType === 'kv' && !buffer.q) {
|
1723
|
+
buffer.dType = undefined;
|
1724
|
+
}
|
1725
|
+
}
|
1726
|
+
|
1727
|
+
ret.push({
|
1728
|
+
type_: 'chemfive',
|
1729
|
+
a: mhchemParser.go(buffer.a, 'a'),
|
1730
|
+
b: mhchemParser.go(buffer.b, 'bd'),
|
1731
|
+
p: mhchemParser.go(buffer.p, 'pq'),
|
1732
|
+
o: mhchemParser.go(buffer.o, 'o'),
|
1733
|
+
q: mhchemParser.go(buffer.q, 'pq'),
|
1734
|
+
d: mhchemParser.go(buffer.d, buffer.dType === 'oxidation' ? 'oxidation' : 'bd'),
|
1735
|
+
dType: buffer.dType
|
1736
|
+
});
|
1737
|
+
}
|
1738
|
+
} else {
|
1739
|
+
// r
|
1740
|
+
|
1741
|
+
/** @type {ParserOutput[]} */
|
1742
|
+
var rd;
|
1743
|
+
|
1744
|
+
if (buffer.rdt === 'M') {
|
1745
|
+
rd = mhchemParser.go(buffer.rd, 'tex-math');
|
1746
|
+
} else if (buffer.rdt === 'T') {
|
1747
|
+
rd = [{
|
1748
|
+
type_: 'text',
|
1749
|
+
p1: buffer.rd || ""
|
1750
|
+
}];
|
1751
|
+
} else {
|
1752
|
+
rd = mhchemParser.go(buffer.rd);
|
1753
|
+
}
|
1754
|
+
/** @type {ParserOutput[]} */
|
1755
|
+
|
1756
|
+
|
1757
|
+
var rq;
|
1758
|
+
|
1759
|
+
if (buffer.rqt === 'M') {
|
1760
|
+
rq = mhchemParser.go(buffer.rq, 'tex-math');
|
1761
|
+
} else if (buffer.rqt === 'T') {
|
1762
|
+
rq = [{
|
1763
|
+
type_: 'text',
|
1764
|
+
p1: buffer.rq || ""
|
1765
|
+
}];
|
1766
|
+
} else {
|
1767
|
+
rq = mhchemParser.go(buffer.rq);
|
1768
|
+
}
|
1769
|
+
|
1770
|
+
ret = {
|
1771
|
+
type_: 'arrow',
|
1772
|
+
r: buffer.r,
|
1773
|
+
rd: rd,
|
1774
|
+
rq: rq
|
1775
|
+
};
|
1776
|
+
}
|
1777
|
+
|
1778
|
+
for (var p in buffer) {
|
1779
|
+
if (p !== 'parenthesisLevel' && p !== 'beginsWithBond') {
|
1780
|
+
delete buffer[p];
|
1781
|
+
}
|
1782
|
+
}
|
1783
|
+
|
1784
|
+
return ret;
|
1785
|
+
},
|
1786
|
+
'oxidation-output': function oxidationOutput(buffer, m) {
|
1787
|
+
var ret = ["{"];
|
1788
|
+
mhchemParser.concatArray(ret, mhchemParser.go(m, 'oxidation'));
|
1789
|
+
ret.push("}");
|
1790
|
+
return ret;
|
1791
|
+
},
|
1792
|
+
'frac-output': function fracOutput(buffer, m) {
|
1793
|
+
return {
|
1794
|
+
type_: 'frac-ce',
|
1795
|
+
p1: mhchemParser.go(m[0]),
|
1796
|
+
p2: mhchemParser.go(m[1])
|
1797
|
+
};
|
1798
|
+
},
|
1799
|
+
'overset-output': function oversetOutput(buffer, m) {
|
1800
|
+
return {
|
1801
|
+
type_: 'overset',
|
1802
|
+
p1: mhchemParser.go(m[0]),
|
1803
|
+
p2: mhchemParser.go(m[1])
|
1804
|
+
};
|
1805
|
+
},
|
1806
|
+
'underset-output': function undersetOutput(buffer, m) {
|
1807
|
+
return {
|
1808
|
+
type_: 'underset',
|
1809
|
+
p1: mhchemParser.go(m[0]),
|
1810
|
+
p2: mhchemParser.go(m[1])
|
1811
|
+
};
|
1812
|
+
},
|
1813
|
+
'underbrace-output': function underbraceOutput(buffer, m) {
|
1814
|
+
return {
|
1815
|
+
type_: 'underbrace',
|
1816
|
+
p1: mhchemParser.go(m[0]),
|
1817
|
+
p2: mhchemParser.go(m[1])
|
1818
|
+
};
|
1819
|
+
},
|
1820
|
+
'color-output': function colorOutput(buffer, m) {
|
1821
|
+
return {
|
1822
|
+
type_: 'color',
|
1823
|
+
color1: m[0],
|
1824
|
+
color2: mhchemParser.go(m[1])
|
1825
|
+
};
|
1826
|
+
},
|
1827
|
+
'r=': function r(buffer, m) {
|
1828
|
+
buffer.r = m;
|
1829
|
+
},
|
1830
|
+
'rdt=': function rdt(buffer, m) {
|
1831
|
+
buffer.rdt = m;
|
1832
|
+
},
|
1833
|
+
'rd=': function rd(buffer, m) {
|
1834
|
+
buffer.rd = m;
|
1835
|
+
},
|
1836
|
+
'rqt=': function rqt(buffer, m) {
|
1837
|
+
buffer.rqt = m;
|
1838
|
+
},
|
1839
|
+
'rq=': function rq(buffer, m) {
|
1840
|
+
buffer.rq = m;
|
1841
|
+
},
|
1842
|
+
'operator': function operator(buffer, m, p1) {
|
1843
|
+
return {
|
1844
|
+
type_: 'operator',
|
1845
|
+
kind_: p1 || m
|
1846
|
+
};
|
1847
|
+
}
|
1848
|
+
}
|
1849
|
+
},
|
1850
|
+
'a': {
|
1851
|
+
transitions: mhchemParser.createTransitions({
|
1852
|
+
'empty': {
|
1853
|
+
'*': {}
|
1854
|
+
},
|
1855
|
+
'1/2$': {
|
1856
|
+
'0': {
|
1857
|
+
action_: '1/2'
|
1858
|
+
}
|
1859
|
+
},
|
1860
|
+
'else': {
|
1861
|
+
'0': {
|
1862
|
+
nextState: '1',
|
1863
|
+
revisit: true
|
1864
|
+
}
|
1865
|
+
},
|
1866
|
+
'$(...)$': {
|
1867
|
+
'*': {
|
1868
|
+
action_: 'tex-math tight',
|
1869
|
+
nextState: '1'
|
1870
|
+
}
|
1871
|
+
},
|
1872
|
+
',': {
|
1873
|
+
'*': {
|
1874
|
+
action_: {
|
1875
|
+
type_: 'insert',
|
1876
|
+
option: 'commaDecimal'
|
1877
|
+
}
|
1878
|
+
}
|
1879
|
+
},
|
1880
|
+
'else2': {
|
1881
|
+
'*': {
|
1882
|
+
action_: 'copy'
|
1883
|
+
}
|
1884
|
+
}
|
1885
|
+
}),
|
1886
|
+
actions: {}
|
1887
|
+
},
|
1888
|
+
'o': {
|
1889
|
+
transitions: mhchemParser.createTransitions({
|
1890
|
+
'empty': {
|
1891
|
+
'*': {}
|
1892
|
+
},
|
1893
|
+
'1/2$': {
|
1894
|
+
'0': {
|
1895
|
+
action_: '1/2'
|
1896
|
+
}
|
1897
|
+
},
|
1898
|
+
'else': {
|
1899
|
+
'0': {
|
1900
|
+
nextState: '1',
|
1901
|
+
revisit: true
|
1902
|
+
}
|
1903
|
+
},
|
1904
|
+
'letters': {
|
1905
|
+
'*': {
|
1906
|
+
action_: 'rm'
|
1907
|
+
}
|
1908
|
+
},
|
1909
|
+
'\\ca': {
|
1910
|
+
'*': {
|
1911
|
+
action_: {
|
1912
|
+
type_: 'insert',
|
1913
|
+
option: 'circa'
|
1914
|
+
}
|
1915
|
+
}
|
1916
|
+
},
|
1917
|
+
'\\x{}{}|\\x{}|\\x': {
|
1918
|
+
'*': {
|
1919
|
+
action_: 'copy'
|
1920
|
+
}
|
1921
|
+
},
|
1922
|
+
'${(...)}$|$(...)$': {
|
1923
|
+
'*': {
|
1924
|
+
action_: 'tex-math'
|
1925
|
+
}
|
1926
|
+
},
|
1927
|
+
'{(...)}': {
|
1928
|
+
'*': {
|
1929
|
+
action_: '{text}'
|
1930
|
+
}
|
1931
|
+
},
|
1932
|
+
'else2': {
|
1933
|
+
'*': {
|
1934
|
+
action_: 'copy'
|
1935
|
+
}
|
1936
|
+
}
|
1937
|
+
}),
|
1938
|
+
actions: {}
|
1939
|
+
},
|
1940
|
+
'text': {
|
1941
|
+
transitions: mhchemParser.createTransitions({
|
1942
|
+
'empty': {
|
1943
|
+
'*': {
|
1944
|
+
action_: 'output'
|
1945
|
+
}
|
1946
|
+
},
|
1947
|
+
'{...}': {
|
1948
|
+
'*': {
|
1949
|
+
action_: 'text='
|
1950
|
+
}
|
1951
|
+
},
|
1952
|
+
'${(...)}$|$(...)$': {
|
1953
|
+
'*': {
|
1954
|
+
action_: 'tex-math'
|
1955
|
+
}
|
1956
|
+
},
|
1957
|
+
'\\greek': {
|
1958
|
+
'*': {
|
1959
|
+
action_: ['output', 'rm']
|
1960
|
+
}
|
1961
|
+
},
|
1962
|
+
'\\,|\\x{}{}|\\x{}|\\x': {
|
1963
|
+
'*': {
|
1964
|
+
action_: ['output', 'copy']
|
1965
|
+
}
|
1966
|
+
},
|
1967
|
+
'else': {
|
1968
|
+
'*': {
|
1969
|
+
action_: 'text='
|
1970
|
+
}
|
1971
|
+
}
|
1972
|
+
}),
|
1973
|
+
actions: {
|
1974
|
+
'output': function output(buffer) {
|
1975
|
+
if (buffer.text_) {
|
1976
|
+
/** @type {ParserOutput} */
|
1977
|
+
var ret = {
|
1978
|
+
type_: 'text',
|
1979
|
+
p1: buffer.text_
|
1980
|
+
};
|
1981
|
+
|
1982
|
+
for (var p in buffer) {
|
1983
|
+
delete buffer[p];
|
1984
|
+
}
|
1985
|
+
|
1986
|
+
return ret;
|
1987
|
+
}
|
1988
|
+
}
|
1989
|
+
}
|
1990
|
+
},
|
1991
|
+
'pq': {
|
1992
|
+
transitions: mhchemParser.createTransitions({
|
1993
|
+
'empty': {
|
1994
|
+
'*': {}
|
1995
|
+
},
|
1996
|
+
'state of aggregation $': {
|
1997
|
+
'*': {
|
1998
|
+
action_: 'state of aggregation'
|
1999
|
+
}
|
2000
|
+
},
|
2001
|
+
'i$': {
|
2002
|
+
'0': {
|
2003
|
+
nextState: '!f',
|
2004
|
+
revisit: true
|
2005
|
+
}
|
2006
|
+
},
|
2007
|
+
'(KV letters),': {
|
2008
|
+
'0': {
|
2009
|
+
action_: 'rm',
|
2010
|
+
nextState: '0'
|
2011
|
+
}
|
2012
|
+
},
|
2013
|
+
'formula$': {
|
2014
|
+
'0': {
|
2015
|
+
nextState: 'f',
|
2016
|
+
revisit: true
|
2017
|
+
}
|
2018
|
+
},
|
2019
|
+
'1/2$': {
|
2020
|
+
'0': {
|
2021
|
+
action_: '1/2'
|
2022
|
+
}
|
2023
|
+
},
|
2024
|
+
'else': {
|
2025
|
+
'0': {
|
2026
|
+
nextState: '!f',
|
2027
|
+
revisit: true
|
2028
|
+
}
|
2029
|
+
},
|
2030
|
+
'${(...)}$|$(...)$': {
|
2031
|
+
'*': {
|
2032
|
+
action_: 'tex-math'
|
2033
|
+
}
|
2034
|
+
},
|
2035
|
+
'{(...)}': {
|
2036
|
+
'*': {
|
2037
|
+
action_: 'text'
|
2038
|
+
}
|
2039
|
+
},
|
2040
|
+
'a-z': {
|
2041
|
+
'f': {
|
2042
|
+
action_: 'tex-math'
|
2043
|
+
}
|
2044
|
+
},
|
2045
|
+
'letters': {
|
2046
|
+
'*': {
|
2047
|
+
action_: 'rm'
|
2048
|
+
}
|
2049
|
+
},
|
2050
|
+
'-9.,9': {
|
2051
|
+
'*': {
|
2052
|
+
action_: '9,9'
|
2053
|
+
}
|
2054
|
+
},
|
2055
|
+
',': {
|
2056
|
+
'*': {
|
2057
|
+
action_: {
|
2058
|
+
type_: 'insert+p1',
|
2059
|
+
option: 'comma enumeration S'
|
2060
|
+
}
|
2061
|
+
}
|
2062
|
+
},
|
2063
|
+
'\\color{(...)}{(...)}1|\\color(...){(...)}2': {
|
2064
|
+
'*': {
|
2065
|
+
action_: 'color-output'
|
2066
|
+
}
|
2067
|
+
},
|
2068
|
+
'\\color{(...)}0': {
|
2069
|
+
'*': {
|
2070
|
+
action_: 'color0-output'
|
2071
|
+
}
|
2072
|
+
},
|
2073
|
+
'\\ce{(...)}': {
|
2074
|
+
'*': {
|
2075
|
+
action_: 'ce'
|
2076
|
+
}
|
2077
|
+
},
|
2078
|
+
'\\,|\\x{}{}|\\x{}|\\x': {
|
2079
|
+
'*': {
|
2080
|
+
action_: 'copy'
|
2081
|
+
}
|
2082
|
+
},
|
2083
|
+
'else2': {
|
2084
|
+
'*': {
|
2085
|
+
action_: 'copy'
|
2086
|
+
}
|
2087
|
+
}
|
2088
|
+
}),
|
2089
|
+
actions: {
|
2090
|
+
'state of aggregation': function stateOfAggregation(buffer, m) {
|
2091
|
+
return {
|
2092
|
+
type_: 'state of aggregation subscript',
|
2093
|
+
p1: mhchemParser.go(m, 'o')
|
2094
|
+
};
|
2095
|
+
},
|
2096
|
+
'color-output': function colorOutput(buffer, m) {
|
2097
|
+
return {
|
2098
|
+
type_: 'color',
|
2099
|
+
color1: m[0],
|
2100
|
+
color2: mhchemParser.go(m[1], 'pq')
|
2101
|
+
};
|
2102
|
+
}
|
2103
|
+
}
|
2104
|
+
},
|
2105
|
+
'bd': {
|
2106
|
+
transitions: mhchemParser.createTransitions({
|
2107
|
+
'empty': {
|
2108
|
+
'*': {}
|
2109
|
+
},
|
2110
|
+
'x$': {
|
2111
|
+
'0': {
|
2112
|
+
nextState: '!f',
|
2113
|
+
revisit: true
|
2114
|
+
}
|
2115
|
+
},
|
2116
|
+
'formula$': {
|
2117
|
+
'0': {
|
2118
|
+
nextState: 'f',
|
2119
|
+
revisit: true
|
2120
|
+
}
|
2121
|
+
},
|
2122
|
+
'else': {
|
2123
|
+
'0': {
|
2124
|
+
nextState: '!f',
|
2125
|
+
revisit: true
|
2126
|
+
}
|
2127
|
+
},
|
2128
|
+
'-9.,9 no missing 0': {
|
2129
|
+
'*': {
|
2130
|
+
action_: '9,9'
|
2131
|
+
}
|
2132
|
+
},
|
2133
|
+
'.': {
|
2134
|
+
'*': {
|
2135
|
+
action_: {
|
2136
|
+
type_: 'insert',
|
2137
|
+
option: 'electron dot'
|
2138
|
+
}
|
2139
|
+
}
|
2140
|
+
},
|
2141
|
+
'a-z': {
|
2142
|
+
'f': {
|
2143
|
+
action_: 'tex-math'
|
2144
|
+
}
|
2145
|
+
},
|
2146
|
+
'x': {
|
2147
|
+
'*': {
|
2148
|
+
action_: {
|
2149
|
+
type_: 'insert',
|
2150
|
+
option: 'KV x'
|
2151
|
+
}
|
2152
|
+
}
|
2153
|
+
},
|
2154
|
+
'letters': {
|
2155
|
+
'*': {
|
2156
|
+
action_: 'rm'
|
2157
|
+
}
|
2158
|
+
},
|
2159
|
+
'\'': {
|
2160
|
+
'*': {
|
2161
|
+
action_: {
|
2162
|
+
type_: 'insert',
|
2163
|
+
option: 'prime'
|
2164
|
+
}
|
2165
|
+
}
|
2166
|
+
},
|
2167
|
+
'${(...)}$|$(...)$': {
|
2168
|
+
'*': {
|
2169
|
+
action_: 'tex-math'
|
2170
|
+
}
|
2171
|
+
},
|
2172
|
+
'{(...)}': {
|
2173
|
+
'*': {
|
2174
|
+
action_: 'text'
|
2175
|
+
}
|
2176
|
+
},
|
2177
|
+
'\\color{(...)}{(...)}1|\\color(...){(...)}2': {
|
2178
|
+
'*': {
|
2179
|
+
action_: 'color-output'
|
2180
|
+
}
|
2181
|
+
},
|
2182
|
+
'\\color{(...)}0': {
|
2183
|
+
'*': {
|
2184
|
+
action_: 'color0-output'
|
2185
|
+
}
|
2186
|
+
},
|
2187
|
+
'\\ce{(...)}': {
|
2188
|
+
'*': {
|
2189
|
+
action_: 'ce'
|
2190
|
+
}
|
2191
|
+
},
|
2192
|
+
'\\,|\\x{}{}|\\x{}|\\x': {
|
2193
|
+
'*': {
|
2194
|
+
action_: 'copy'
|
2195
|
+
}
|
2196
|
+
},
|
2197
|
+
'else2': {
|
2198
|
+
'*': {
|
2199
|
+
action_: 'copy'
|
2200
|
+
}
|
2201
|
+
}
|
2202
|
+
}),
|
2203
|
+
actions: {
|
2204
|
+
'color-output': function colorOutput(buffer, m) {
|
2205
|
+
return {
|
2206
|
+
type_: 'color',
|
2207
|
+
color1: m[0],
|
2208
|
+
color2: mhchemParser.go(m[1], 'bd')
|
2209
|
+
};
|
2210
|
+
}
|
2211
|
+
}
|
2212
|
+
},
|
2213
|
+
'oxidation': {
|
2214
|
+
transitions: mhchemParser.createTransitions({
|
2215
|
+
'empty': {
|
2216
|
+
'*': {}
|
2217
|
+
},
|
2218
|
+
'roman numeral': {
|
2219
|
+
'*': {
|
2220
|
+
action_: 'roman-numeral'
|
2221
|
+
}
|
2222
|
+
},
|
2223
|
+
'${(...)}$|$(...)$': {
|
2224
|
+
'*': {
|
2225
|
+
action_: 'tex-math'
|
2226
|
+
}
|
2227
|
+
},
|
2228
|
+
'else': {
|
2229
|
+
'*': {
|
2230
|
+
action_: 'copy'
|
2231
|
+
}
|
2232
|
+
}
|
2233
|
+
}),
|
2234
|
+
actions: {
|
2235
|
+
'roman-numeral': function romanNumeral(buffer, m) {
|
2236
|
+
return {
|
2237
|
+
type_: 'roman numeral',
|
2238
|
+
p1: m || ""
|
2239
|
+
};
|
2240
|
+
}
|
2241
|
+
}
|
2242
|
+
},
|
2243
|
+
'tex-math': {
|
2244
|
+
transitions: mhchemParser.createTransitions({
|
2245
|
+
'empty': {
|
2246
|
+
'*': {
|
2247
|
+
action_: 'output'
|
2248
|
+
}
|
2249
|
+
},
|
2250
|
+
'\\ce{(...)}': {
|
2251
|
+
'*': {
|
2252
|
+
action_: ['output', 'ce']
|
2253
|
+
}
|
2254
|
+
},
|
2255
|
+
'{...}|\\,|\\x{}{}|\\x{}|\\x': {
|
2256
|
+
'*': {
|
2257
|
+
action_: 'o='
|
2258
|
+
}
|
2259
|
+
},
|
2260
|
+
'else': {
|
2261
|
+
'*': {
|
2262
|
+
action_: 'o='
|
2263
|
+
}
|
2264
|
+
}
|
2265
|
+
}),
|
2266
|
+
actions: {
|
2267
|
+
'output': function output(buffer) {
|
2268
|
+
if (buffer.o) {
|
2269
|
+
/** @type {ParserOutput} */
|
2270
|
+
var ret = {
|
2271
|
+
type_: 'tex-math',
|
2272
|
+
p1: buffer.o
|
2273
|
+
};
|
2274
|
+
|
2275
|
+
for (var p in buffer) {
|
2276
|
+
delete buffer[p];
|
2277
|
+
}
|
2278
|
+
|
2279
|
+
return ret;
|
2280
|
+
}
|
2281
|
+
}
|
2282
|
+
}
|
2283
|
+
},
|
2284
|
+
'tex-math tight': {
|
2285
|
+
transitions: mhchemParser.createTransitions({
|
2286
|
+
'empty': {
|
2287
|
+
'*': {
|
2288
|
+
action_: 'output'
|
2289
|
+
}
|
2290
|
+
},
|
2291
|
+
'\\ce{(...)}': {
|
2292
|
+
'*': {
|
2293
|
+
action_: ['output', 'ce']
|
2294
|
+
}
|
2295
|
+
},
|
2296
|
+
'{...}|\\,|\\x{}{}|\\x{}|\\x': {
|
2297
|
+
'*': {
|
2298
|
+
action_: 'o='
|
2299
|
+
}
|
2300
|
+
},
|
2301
|
+
'-|+': {
|
2302
|
+
'*': {
|
2303
|
+
action_: 'tight operator'
|
2304
|
+
}
|
2305
|
+
},
|
2306
|
+
'else': {
|
2307
|
+
'*': {
|
2308
|
+
action_: 'o='
|
2309
|
+
}
|
2310
|
+
}
|
2311
|
+
}),
|
2312
|
+
actions: {
|
2313
|
+
'tight operator': function tightOperator(buffer, m) {
|
2314
|
+
buffer.o = (buffer.o || "") + "{" + m + "}";
|
2315
|
+
},
|
2316
|
+
'output': function output(buffer) {
|
2317
|
+
if (buffer.o) {
|
2318
|
+
/** @type {ParserOutput} */
|
2319
|
+
var ret = {
|
2320
|
+
type_: 'tex-math',
|
2321
|
+
p1: buffer.o
|
2322
|
+
};
|
2323
|
+
|
2324
|
+
for (var p in buffer) {
|
2325
|
+
delete buffer[p];
|
2326
|
+
}
|
2327
|
+
|
2328
|
+
return ret;
|
2329
|
+
}
|
2330
|
+
}
|
2331
|
+
}
|
2332
|
+
},
|
2333
|
+
'9,9': {
|
2334
|
+
transitions: mhchemParser.createTransitions({
|
2335
|
+
'empty': {
|
2336
|
+
'*': {}
|
2337
|
+
},
|
2338
|
+
',': {
|
2339
|
+
'*': {
|
2340
|
+
action_: 'comma'
|
2341
|
+
}
|
2342
|
+
},
|
2343
|
+
'else': {
|
2344
|
+
'*': {
|
2345
|
+
action_: 'copy'
|
2346
|
+
}
|
2347
|
+
}
|
2348
|
+
}),
|
2349
|
+
actions: {
|
2350
|
+
'comma': function comma() {
|
2351
|
+
return {
|
2352
|
+
type_: 'commaDecimal'
|
2353
|
+
};
|
2354
|
+
}
|
2355
|
+
}
|
2356
|
+
},
|
2357
|
+
//#endregion
|
2358
|
+
//
|
2359
|
+
// \pu state machines
|
2360
|
+
//
|
2361
|
+
//#region pu
|
2362
|
+
'pu': {
|
2363
|
+
transitions: mhchemParser.createTransitions({
|
2364
|
+
'empty': {
|
2365
|
+
'*': {
|
2366
|
+
action_: 'output'
|
2367
|
+
}
|
2368
|
+
},
|
2369
|
+
'space$': {
|
2370
|
+
'*': {
|
2371
|
+
action_: ['output', 'space']
|
2372
|
+
}
|
2373
|
+
},
|
2374
|
+
'{[(|)]}': {
|
2375
|
+
'0|a': {
|
2376
|
+
action_: 'copy'
|
2377
|
+
}
|
2378
|
+
},
|
2379
|
+
'(-)(9)^(-9)': {
|
2380
|
+
'0': {
|
2381
|
+
action_: 'number^',
|
2382
|
+
nextState: 'a'
|
2383
|
+
}
|
2384
|
+
},
|
2385
|
+
'(-)(9.,9)(e)(99)': {
|
2386
|
+
'0': {
|
2387
|
+
action_: 'enumber',
|
2388
|
+
nextState: 'a'
|
2389
|
+
}
|
2390
|
+
},
|
2391
|
+
'space': {
|
2392
|
+
'0|a': {}
|
2393
|
+
},
|
2394
|
+
'pm-operator': {
|
2395
|
+
'0|a': {
|
2396
|
+
action_: {
|
2397
|
+
type_: 'operator',
|
2398
|
+
option: '\\pm'
|
2399
|
+
},
|
2400
|
+
nextState: '0'
|
2401
|
+
}
|
2402
|
+
},
|
2403
|
+
'operator': {
|
2404
|
+
'0|a': {
|
2405
|
+
action_: 'copy',
|
2406
|
+
nextState: '0'
|
2407
|
+
}
|
2408
|
+
},
|
2409
|
+
'//': {
|
2410
|
+
'd': {
|
2411
|
+
action_: 'o=',
|
2412
|
+
nextState: '/'
|
2413
|
+
}
|
2414
|
+
},
|
2415
|
+
'/': {
|
2416
|
+
'd': {
|
2417
|
+
action_: 'o=',
|
2418
|
+
nextState: '/'
|
2419
|
+
}
|
2420
|
+
},
|
2421
|
+
'{...}|else': {
|
2422
|
+
'0|d': {
|
2423
|
+
action_: 'd=',
|
2424
|
+
nextState: 'd'
|
2425
|
+
},
|
2426
|
+
'a': {
|
2427
|
+
action_: ['space', 'd='],
|
2428
|
+
nextState: 'd'
|
2429
|
+
},
|
2430
|
+
'/|q': {
|
2431
|
+
action_: 'q=',
|
2432
|
+
nextState: 'q'
|
2433
|
+
}
|
2434
|
+
}
|
2435
|
+
}),
|
2436
|
+
actions: {
|
2437
|
+
'enumber': function enumber(buffer, m) {
|
2438
|
+
/** @type {ParserOutput[]} */
|
2439
|
+
var ret = [];
|
2440
|
+
|
2441
|
+
if (m[0] === "+-" || m[0] === "+/-") {
|
2442
|
+
ret.push("\\pm ");
|
2443
|
+
} else if (m[0]) {
|
2444
|
+
ret.push(m[0]);
|
2445
|
+
}
|
2446
|
+
|
2447
|
+
if (m[1]) {
|
2448
|
+
mhchemParser.concatArray(ret, mhchemParser.go(m[1], 'pu-9,9'));
|
2449
|
+
|
2450
|
+
if (m[2]) {
|
2451
|
+
if (m[2].match(/[,.]/)) {
|
2452
|
+
mhchemParser.concatArray(ret, mhchemParser.go(m[2], 'pu-9,9'));
|
2453
|
+
} else {
|
2454
|
+
ret.push(m[2]);
|
2455
|
+
}
|
2456
|
+
}
|
2457
|
+
|
2458
|
+
m[3] = m[4] || m[3];
|
2459
|
+
|
2460
|
+
if (m[3]) {
|
2461
|
+
m[3] = m[3].trim();
|
2462
|
+
|
2463
|
+
if (m[3] === "e" || m[3].substr(0, 1) === "*") {
|
2464
|
+
ret.push({
|
2465
|
+
type_: 'cdot'
|
2466
|
+
});
|
2467
|
+
} else {
|
2468
|
+
ret.push({
|
2469
|
+
type_: 'times'
|
2470
|
+
});
|
2471
|
+
}
|
2472
|
+
}
|
2473
|
+
}
|
2474
|
+
|
2475
|
+
if (m[3]) {
|
2476
|
+
ret.push("10^{" + m[5] + "}");
|
2477
|
+
}
|
2478
|
+
|
2479
|
+
return ret;
|
2480
|
+
},
|
2481
|
+
'number^': function number(buffer, m) {
|
2482
|
+
/** @type {ParserOutput[]} */
|
2483
|
+
var ret = [];
|
2484
|
+
|
2485
|
+
if (m[0] === "+-" || m[0] === "+/-") {
|
2486
|
+
ret.push("\\pm ");
|
2487
|
+
} else if (m[0]) {
|
2488
|
+
ret.push(m[0]);
|
2489
|
+
}
|
2490
|
+
|
2491
|
+
mhchemParser.concatArray(ret, mhchemParser.go(m[1], 'pu-9,9'));
|
2492
|
+
ret.push("^{" + m[2] + "}");
|
2493
|
+
return ret;
|
2494
|
+
},
|
2495
|
+
'operator': function operator(buffer, m, p1) {
|
2496
|
+
return {
|
2497
|
+
type_: 'operator',
|
2498
|
+
kind_: p1 || m
|
2499
|
+
};
|
2500
|
+
},
|
2501
|
+
'space': function space() {
|
2502
|
+
return {
|
2503
|
+
type_: 'pu-space-1'
|
2504
|
+
};
|
2505
|
+
},
|
2506
|
+
'output': function output(buffer) {
|
2507
|
+
/** @type {ParserOutput | ParserOutput[]} */
|
2508
|
+
var ret;
|
2509
|
+
var md = mhchemParser.patterns.match_('{(...)}', buffer.d || "");
|
2510
|
+
|
2511
|
+
if (md && md.remainder === '') {
|
2512
|
+
buffer.d = md.match_;
|
2513
|
+
}
|
2514
|
+
|
2515
|
+
var mq = mhchemParser.patterns.match_('{(...)}', buffer.q || "");
|
2516
|
+
|
2517
|
+
if (mq && mq.remainder === '') {
|
2518
|
+
buffer.q = mq.match_;
|
2519
|
+
}
|
2520
|
+
|
2521
|
+
if (buffer.d) {
|
2522
|
+
buffer.d = buffer.d.replace(/\u00B0C|\^oC|\^{o}C/g, "{}^{\\circ}C");
|
2523
|
+
buffer.d = buffer.d.replace(/\u00B0F|\^oF|\^{o}F/g, "{}^{\\circ}F");
|
2524
|
+
}
|
2525
|
+
|
2526
|
+
if (buffer.q) {
|
2527
|
+
// fraction
|
2528
|
+
buffer.q = buffer.q.replace(/\u00B0C|\^oC|\^{o}C/g, "{}^{\\circ}C");
|
2529
|
+
buffer.q = buffer.q.replace(/\u00B0F|\^oF|\^{o}F/g, "{}^{\\circ}F");
|
2530
|
+
var b5 = {
|
2531
|
+
d: mhchemParser.go(buffer.d, 'pu'),
|
2532
|
+
q: mhchemParser.go(buffer.q, 'pu')
|
2533
|
+
};
|
2534
|
+
|
2535
|
+
if (buffer.o === '//') {
|
2536
|
+
ret = {
|
2537
|
+
type_: 'pu-frac',
|
2538
|
+
p1: b5.d,
|
2539
|
+
p2: b5.q
|
2540
|
+
};
|
2541
|
+
} else {
|
2542
|
+
ret = b5.d;
|
2543
|
+
|
2544
|
+
if (b5.d.length > 1 || b5.q.length > 1) {
|
2545
|
+
ret.push({
|
2546
|
+
type_: ' / '
|
2547
|
+
});
|
2548
|
+
} else {
|
2549
|
+
ret.push({
|
2550
|
+
type_: '/'
|
2551
|
+
});
|
2552
|
+
}
|
2553
|
+
|
2554
|
+
mhchemParser.concatArray(ret, b5.q);
|
2555
|
+
}
|
2556
|
+
} else {
|
2557
|
+
// no fraction
|
2558
|
+
ret = mhchemParser.go(buffer.d, 'pu-2');
|
2559
|
+
}
|
2560
|
+
|
2561
|
+
for (var p in buffer) {
|
2562
|
+
delete buffer[p];
|
2563
|
+
}
|
2564
|
+
|
2565
|
+
return ret;
|
2566
|
+
}
|
2567
|
+
}
|
2568
|
+
},
|
2569
|
+
'pu-2': {
|
2570
|
+
transitions: mhchemParser.createTransitions({
|
2571
|
+
'empty': {
|
2572
|
+
'*': {
|
2573
|
+
action_: 'output'
|
2574
|
+
}
|
2575
|
+
},
|
2576
|
+
'*': {
|
2577
|
+
'*': {
|
2578
|
+
action_: ['output', 'cdot'],
|
2579
|
+
nextState: '0'
|
2580
|
+
}
|
2581
|
+
},
|
2582
|
+
'\\x': {
|
2583
|
+
'*': {
|
2584
|
+
action_: 'rm='
|
2585
|
+
}
|
2586
|
+
},
|
2587
|
+
'space': {
|
2588
|
+
'*': {
|
2589
|
+
action_: ['output', 'space'],
|
2590
|
+
nextState: '0'
|
2591
|
+
}
|
2592
|
+
},
|
2593
|
+
'^{(...)}|^(-1)': {
|
2594
|
+
'1': {
|
2595
|
+
action_: '^(-1)'
|
2596
|
+
}
|
2597
|
+
},
|
2598
|
+
'-9.,9': {
|
2599
|
+
'0': {
|
2600
|
+
action_: 'rm=',
|
2601
|
+
nextState: '0'
|
2602
|
+
},
|
2603
|
+
'1': {
|
2604
|
+
action_: '^(-1)',
|
2605
|
+
nextState: '0'
|
2606
|
+
}
|
2607
|
+
},
|
2608
|
+
'{...}|else': {
|
2609
|
+
'*': {
|
2610
|
+
action_: 'rm=',
|
2611
|
+
nextState: '1'
|
2612
|
+
}
|
2613
|
+
}
|
2614
|
+
}),
|
2615
|
+
actions: {
|
2616
|
+
'cdot': function cdot() {
|
2617
|
+
return {
|
2618
|
+
type_: 'tight cdot'
|
2619
|
+
};
|
2620
|
+
},
|
2621
|
+
'^(-1)': function _(buffer, m) {
|
2622
|
+
buffer.rm += "^{" + m + "}";
|
2623
|
+
},
|
2624
|
+
'space': function space() {
|
2625
|
+
return {
|
2626
|
+
type_: 'pu-space-2'
|
2627
|
+
};
|
2628
|
+
},
|
2629
|
+
'output': function output(buffer) {
|
2630
|
+
/** @type {ParserOutput | ParserOutput[]} */
|
2631
|
+
var ret = [];
|
2632
|
+
|
2633
|
+
if (buffer.rm) {
|
2634
|
+
var mrm = mhchemParser.patterns.match_('{(...)}', buffer.rm || "");
|
2635
|
+
|
2636
|
+
if (mrm && mrm.remainder === '') {
|
2637
|
+
ret = mhchemParser.go(mrm.match_, 'pu');
|
2638
|
+
} else {
|
2639
|
+
ret = {
|
2640
|
+
type_: 'rm',
|
2641
|
+
p1: buffer.rm
|
2642
|
+
};
|
2643
|
+
}
|
2644
|
+
}
|
2645
|
+
|
2646
|
+
for (var p in buffer) {
|
2647
|
+
delete buffer[p];
|
2648
|
+
}
|
2649
|
+
|
2650
|
+
return ret;
|
2651
|
+
}
|
2652
|
+
}
|
2653
|
+
},
|
2654
|
+
'pu-9,9': {
|
2655
|
+
transitions: mhchemParser.createTransitions({
|
2656
|
+
'empty': {
|
2657
|
+
'0': {
|
2658
|
+
action_: 'output-0'
|
2659
|
+
},
|
2660
|
+
'o': {
|
2661
|
+
action_: 'output-o'
|
2662
|
+
}
|
2663
|
+
},
|
2664
|
+
',': {
|
2665
|
+
'0': {
|
2666
|
+
action_: ['output-0', 'comma'],
|
2667
|
+
nextState: 'o'
|
2668
|
+
}
|
2669
|
+
},
|
2670
|
+
'.': {
|
2671
|
+
'0': {
|
2672
|
+
action_: ['output-0', 'copy'],
|
2673
|
+
nextState: 'o'
|
2674
|
+
}
|
2675
|
+
},
|
2676
|
+
'else': {
|
2677
|
+
'*': {
|
2678
|
+
action_: 'text='
|
2679
|
+
}
|
2680
|
+
}
|
2681
|
+
}),
|
2682
|
+
actions: {
|
2683
|
+
'comma': function comma() {
|
2684
|
+
return {
|
2685
|
+
type_: 'commaDecimal'
|
2686
|
+
};
|
2687
|
+
},
|
2688
|
+
'output-0': function output0(buffer) {
|
2689
|
+
/** @type {ParserOutput[]} */
|
2690
|
+
var ret = [];
|
2691
|
+
buffer.text_ = buffer.text_ || "";
|
2692
|
+
|
2693
|
+
if (buffer.text_.length > 4) {
|
2694
|
+
var a = buffer.text_.length % 3;
|
2695
|
+
|
2696
|
+
if (a === 0) {
|
2697
|
+
a = 3;
|
2698
|
+
}
|
2699
|
+
|
2700
|
+
for (var i = buffer.text_.length - 3; i > 0; i -= 3) {
|
2701
|
+
ret.push(buffer.text_.substr(i, 3));
|
2702
|
+
ret.push({
|
2703
|
+
type_: '1000 separator'
|
2704
|
+
});
|
2705
|
+
}
|
2706
|
+
|
2707
|
+
ret.push(buffer.text_.substr(0, a));
|
2708
|
+
ret.reverse();
|
2709
|
+
} else {
|
2710
|
+
ret.push(buffer.text_);
|
2711
|
+
}
|
2712
|
+
|
2713
|
+
for (var p in buffer) {
|
2714
|
+
delete buffer[p];
|
2715
|
+
}
|
2716
|
+
|
2717
|
+
return ret;
|
2718
|
+
},
|
2719
|
+
'output-o': function outputO(buffer) {
|
2720
|
+
/** @type {ParserOutput[]} */
|
2721
|
+
var ret = [];
|
2722
|
+
buffer.text_ = buffer.text_ || "";
|
2723
|
+
|
2724
|
+
if (buffer.text_.length > 4) {
|
2725
|
+
var a = buffer.text_.length - 3;
|
2726
|
+
|
2727
|
+
for (var i = 0; i < a; i += 3) {
|
2728
|
+
ret.push(buffer.text_.substr(i, 3));
|
2729
|
+
ret.push({
|
2730
|
+
type_: '1000 separator'
|
2731
|
+
});
|
2732
|
+
}
|
2733
|
+
|
2734
|
+
ret.push(buffer.text_.substr(i));
|
2735
|
+
} else {
|
2736
|
+
ret.push(buffer.text_);
|
2737
|
+
}
|
2738
|
+
|
2739
|
+
for (var p in buffer) {
|
2740
|
+
delete buffer[p];
|
2741
|
+
}
|
2742
|
+
|
2743
|
+
return ret;
|
2744
|
+
}
|
2745
|
+
} //#endregion
|
2746
|
+
|
2747
|
+
}
|
2748
|
+
}; //
|
2749
|
+
// texify: Take MhchemParser output and convert it to TeX
|
2750
|
+
//
|
2751
|
+
|
2752
|
+
/** @type {Texify} */
|
2753
|
+
|
2754
|
+
var texify = {
|
2755
|
+
go: function go(input, isInner) {
|
2756
|
+
// (recursive, max 4 levels)
|
2757
|
+
if (!input) {
|
2758
|
+
return "";
|
2759
|
+
}
|
2760
|
+
|
2761
|
+
var res = "";
|
2762
|
+
var cee = false;
|
2763
|
+
|
2764
|
+
for (var i = 0; i < input.length; i++) {
|
2765
|
+
var inputi = input[i];
|
2766
|
+
|
2767
|
+
if (typeof inputi === "string") {
|
2768
|
+
res += inputi;
|
2769
|
+
} else {
|
2770
|
+
res += texify._go2(inputi);
|
2771
|
+
|
2772
|
+
if (inputi.type_ === '1st-level escape') {
|
2773
|
+
cee = true;
|
2774
|
+
}
|
2775
|
+
}
|
2776
|
+
}
|
2777
|
+
|
2778
|
+
if (!isInner && !cee && res) {
|
2779
|
+
res = "{" + res + "}";
|
2780
|
+
}
|
2781
|
+
|
2782
|
+
return res;
|
2783
|
+
},
|
2784
|
+
_goInner: function _goInner(input) {
|
2785
|
+
if (!input) {
|
2786
|
+
return input;
|
2787
|
+
}
|
2788
|
+
|
2789
|
+
return texify.go(input, true);
|
2790
|
+
},
|
2791
|
+
_go2: function _go2(buf) {
|
2792
|
+
/** @type {undefined | string} */
|
2793
|
+
var res;
|
2794
|
+
|
2795
|
+
switch (buf.type_) {
|
2796
|
+
case 'chemfive':
|
2797
|
+
res = "";
|
2798
|
+
var b5 = {
|
2799
|
+
a: texify._goInner(buf.a),
|
2800
|
+
b: texify._goInner(buf.b),
|
2801
|
+
p: texify._goInner(buf.p),
|
2802
|
+
o: texify._goInner(buf.o),
|
2803
|
+
q: texify._goInner(buf.q),
|
2804
|
+
d: texify._goInner(buf.d)
|
2805
|
+
}; //
|
2806
|
+
// a
|
2807
|
+
//
|
2808
|
+
|
2809
|
+
if (b5.a) {
|
2810
|
+
if (b5.a.match(/^[+\-]/)) {
|
2811
|
+
b5.a = "{" + b5.a + "}";
|
2812
|
+
}
|
2813
|
+
|
2814
|
+
res += b5.a + "\\,";
|
2815
|
+
} //
|
2816
|
+
// b and p
|
2817
|
+
//
|
2818
|
+
|
2819
|
+
|
2820
|
+
if (b5.b || b5.p) {
|
2821
|
+
res += "{\\vphantom{X}}";
|
2822
|
+
res += "^{\\hphantom{" + (b5.b || "") + "}}_{\\hphantom{" + (b5.p || "") + "}}";
|
2823
|
+
res += "{\\vphantom{X}}";
|
2824
|
+
res += "^{\\smash[t]{\\vphantom{2}}\\mathllap{" + (b5.b || "") + "}}";
|
2825
|
+
res += "_{\\vphantom{2}\\mathllap{\\smash[t]{" + (b5.p || "") + "}}}";
|
2826
|
+
} //
|
2827
|
+
// o
|
2828
|
+
//
|
2829
|
+
|
2830
|
+
|
2831
|
+
if (b5.o) {
|
2832
|
+
if (b5.o.match(/^[+\-]/)) {
|
2833
|
+
b5.o = "{" + b5.o + "}";
|
2834
|
+
}
|
2835
|
+
|
2836
|
+
res += b5.o;
|
2837
|
+
} //
|
2838
|
+
// q and d
|
2839
|
+
//
|
2840
|
+
|
2841
|
+
|
2842
|
+
if (buf.dType === 'kv') {
|
2843
|
+
if (b5.d || b5.q) {
|
2844
|
+
res += "{\\vphantom{X}}";
|
2845
|
+
}
|
2846
|
+
|
2847
|
+
if (b5.d) {
|
2848
|
+
res += "^{" + b5.d + "}";
|
2849
|
+
}
|
2850
|
+
|
2851
|
+
if (b5.q) {
|
2852
|
+
res += "_{\\smash[t]{" + b5.q + "}}";
|
2853
|
+
}
|
2854
|
+
} else if (buf.dType === 'oxidation') {
|
2855
|
+
if (b5.d) {
|
2856
|
+
res += "{\\vphantom{X}}";
|
2857
|
+
res += "^{" + b5.d + "}";
|
2858
|
+
}
|
2859
|
+
|
2860
|
+
if (b5.q) {
|
2861
|
+
res += "{\\vphantom{X}}";
|
2862
|
+
res += "_{\\smash[t]{" + b5.q + "}}";
|
2863
|
+
}
|
2864
|
+
} else {
|
2865
|
+
if (b5.q) {
|
2866
|
+
res += "{\\vphantom{X}}";
|
2867
|
+
res += "_{\\smash[t]{" + b5.q + "}}";
|
2868
|
+
}
|
2869
|
+
|
2870
|
+
if (b5.d) {
|
2871
|
+
res += "{\\vphantom{X}}";
|
2872
|
+
res += "^{" + b5.d + "}";
|
2873
|
+
}
|
2874
|
+
}
|
2875
|
+
|
2876
|
+
break;
|
2877
|
+
|
2878
|
+
case 'rm':
|
2879
|
+
res = "\\mathrm{" + buf.p1 + "}";
|
2880
|
+
break;
|
2881
|
+
|
2882
|
+
case 'text':
|
2883
|
+
if (buf.p1.match(/[\^_]/)) {
|
2884
|
+
buf.p1 = buf.p1.replace(" ", "~").replace("-", "\\text{-}");
|
2885
|
+
res = "\\mathrm{" + buf.p1 + "}";
|
2886
|
+
} else {
|
2887
|
+
res = "\\text{" + buf.p1 + "}";
|
2888
|
+
}
|
2889
|
+
|
2890
|
+
break;
|
2891
|
+
|
2892
|
+
case 'roman numeral':
|
2893
|
+
res = "\\mathrm{" + buf.p1 + "}";
|
2894
|
+
break;
|
2895
|
+
|
2896
|
+
case 'state of aggregation':
|
2897
|
+
res = "\\mskip2mu " + texify._goInner(buf.p1);
|
2898
|
+
break;
|
2899
|
+
|
2900
|
+
case 'state of aggregation subscript':
|
2901
|
+
res = "\\mskip1mu " + texify._goInner(buf.p1);
|
2902
|
+
break;
|
2903
|
+
|
2904
|
+
case 'bond':
|
2905
|
+
res = texify._getBond(buf.kind_);
|
2906
|
+
|
2907
|
+
if (!res) {
|
2908
|
+
throw ["MhchemErrorBond", "mhchem Error. Unknown bond type (" + buf.kind_ + ")"];
|
2909
|
+
}
|
2910
|
+
|
2911
|
+
break;
|
2912
|
+
|
2913
|
+
case 'frac':
|
2914
|
+
var c = "\\frac{" + buf.p1 + "}{" + buf.p2 + "}";
|
2915
|
+
res = "\\mathchoice{\\textstyle" + c + "}{" + c + "}{" + c + "}{" + c + "}";
|
2916
|
+
break;
|
2917
|
+
|
2918
|
+
case 'pu-frac':
|
2919
|
+
var d = "\\frac{" + texify._goInner(buf.p1) + "}{" + texify._goInner(buf.p2) + "}";
|
2920
|
+
res = "\\mathchoice{\\textstyle" + d + "}{" + d + "}{" + d + "}{" + d + "}";
|
2921
|
+
break;
|
2922
|
+
|
2923
|
+
case 'tex-math':
|
2924
|
+
res = buf.p1 + " ";
|
2925
|
+
break;
|
2926
|
+
|
2927
|
+
case 'frac-ce':
|
2928
|
+
res = "\\frac{" + texify._goInner(buf.p1) + "}{" + texify._goInner(buf.p2) + "}";
|
2929
|
+
break;
|
2930
|
+
|
2931
|
+
case 'overset':
|
2932
|
+
res = "\\overset{" + texify._goInner(buf.p1) + "}{" + texify._goInner(buf.p2) + "}";
|
2933
|
+
break;
|
2934
|
+
|
2935
|
+
case 'underset':
|
2936
|
+
res = "\\underset{" + texify._goInner(buf.p1) + "}{" + texify._goInner(buf.p2) + "}";
|
2937
|
+
break;
|
2938
|
+
|
2939
|
+
case 'underbrace':
|
2940
|
+
res = "\\underbrace{" + texify._goInner(buf.p1) + "}_{" + texify._goInner(buf.p2) + "}";
|
2941
|
+
break;
|
2942
|
+
|
2943
|
+
case 'color':
|
2944
|
+
res = "{\\color{" + buf.color1 + "}{" + texify._goInner(buf.color2) + "}}";
|
2945
|
+
break;
|
2946
|
+
|
2947
|
+
case 'color0':
|
2948
|
+
res = "\\color{" + buf.color + "}";
|
2949
|
+
break;
|
2950
|
+
|
2951
|
+
case 'arrow':
|
2952
|
+
var b6 = {
|
2953
|
+
rd: texify._goInner(buf.rd),
|
2954
|
+
rq: texify._goInner(buf.rq)
|
2955
|
+
};
|
2956
|
+
|
2957
|
+
var arrow = "\\x" + texify._getArrow(buf.r);
|
2958
|
+
|
2959
|
+
if (b6.rq) {
|
2960
|
+
arrow += "[{" + b6.rq + "}]";
|
2961
|
+
}
|
2962
|
+
|
2963
|
+
if (b6.rd) {
|
2964
|
+
arrow += "{" + b6.rd + "}";
|
2965
|
+
} else {
|
2966
|
+
arrow += "{}";
|
2967
|
+
}
|
2968
|
+
|
2969
|
+
res = arrow;
|
2970
|
+
break;
|
2971
|
+
|
2972
|
+
case 'operator':
|
2973
|
+
res = texify._getOperator(buf.kind_);
|
2974
|
+
break;
|
2975
|
+
|
2976
|
+
case '1st-level escape':
|
2977
|
+
res = buf.p1 + " "; // &, \\\\, \\hlin
|
2978
|
+
|
2979
|
+
break;
|
2980
|
+
|
2981
|
+
case 'space':
|
2982
|
+
res = " ";
|
2983
|
+
break;
|
2984
|
+
|
2985
|
+
case 'entitySkip':
|
2986
|
+
res = "~";
|
2987
|
+
break;
|
2988
|
+
|
2989
|
+
case 'pu-space-1':
|
2990
|
+
res = "~";
|
2991
|
+
break;
|
2992
|
+
|
2993
|
+
case 'pu-space-2':
|
2994
|
+
res = "\\mkern3mu ";
|
2995
|
+
break;
|
2996
|
+
|
2997
|
+
case '1000 separator':
|
2998
|
+
res = "\\mkern2mu ";
|
2999
|
+
break;
|
3000
|
+
|
3001
|
+
case 'commaDecimal':
|
3002
|
+
res = "{,}";
|
3003
|
+
break;
|
3004
|
+
|
3005
|
+
case 'comma enumeration L':
|
3006
|
+
res = "{" + buf.p1 + "}\\mkern6mu ";
|
3007
|
+
break;
|
3008
|
+
|
3009
|
+
case 'comma enumeration M':
|
3010
|
+
res = "{" + buf.p1 + "}\\mkern3mu ";
|
3011
|
+
break;
|
3012
|
+
|
3013
|
+
case 'comma enumeration S':
|
3014
|
+
res = "{" + buf.p1 + "}\\mkern1mu ";
|
3015
|
+
break;
|
3016
|
+
|
3017
|
+
case 'hyphen':
|
3018
|
+
res = "\\text{-}";
|
3019
|
+
break;
|
3020
|
+
|
3021
|
+
case 'addition compound':
|
3022
|
+
res = "\\,{\\cdot}\\,";
|
3023
|
+
break;
|
3024
|
+
|
3025
|
+
case 'electron dot':
|
3026
|
+
res = "\\mkern1mu \\bullet\\mkern1mu ";
|
3027
|
+
break;
|
3028
|
+
|
3029
|
+
case 'KV x':
|
3030
|
+
res = "{\\times}";
|
3031
|
+
break;
|
3032
|
+
|
3033
|
+
case 'prime':
|
3034
|
+
res = "\\prime ";
|
3035
|
+
break;
|
3036
|
+
|
3037
|
+
case 'cdot':
|
3038
|
+
res = "\\cdot ";
|
3039
|
+
break;
|
3040
|
+
|
3041
|
+
case 'tight cdot':
|
3042
|
+
res = "\\mkern1mu{\\cdot}\\mkern1mu ";
|
3043
|
+
break;
|
3044
|
+
|
3045
|
+
case 'times':
|
3046
|
+
res = "\\times ";
|
3047
|
+
break;
|
3048
|
+
|
3049
|
+
case 'circa':
|
3050
|
+
res = "{\\sim}";
|
3051
|
+
break;
|
3052
|
+
|
3053
|
+
case '^':
|
3054
|
+
res = "uparrow";
|
3055
|
+
break;
|
3056
|
+
|
3057
|
+
case 'v':
|
3058
|
+
res = "downarrow";
|
3059
|
+
break;
|
3060
|
+
|
3061
|
+
case 'ellipsis':
|
3062
|
+
res = "\\ldots ";
|
3063
|
+
break;
|
3064
|
+
|
3065
|
+
case '/':
|
3066
|
+
res = "/";
|
3067
|
+
break;
|
3068
|
+
|
3069
|
+
case ' / ':
|
3070
|
+
res = "\\,/\\,";
|
3071
|
+
break;
|
3072
|
+
|
3073
|
+
default:
|
3074
|
+
assertNever(buf);
|
3075
|
+
throw ["MhchemBugT", "mhchem bug T. Please report."];
|
3076
|
+
// Missing texify rule or unknown MhchemParser output
|
3077
|
+
}
|
3078
|
+
|
3079
|
+
assertString(res);
|
3080
|
+
return res;
|
3081
|
+
},
|
3082
|
+
_getArrow: function _getArrow(a) {
|
3083
|
+
switch (a) {
|
3084
|
+
case "->":
|
3085
|
+
return "rightarrow";
|
3086
|
+
|
3087
|
+
case "\u2192":
|
3088
|
+
return "rightarrow";
|
3089
|
+
|
3090
|
+
case "\u27F6":
|
3091
|
+
return "rightarrow";
|
3092
|
+
|
3093
|
+
case "<-":
|
3094
|
+
return "leftarrow";
|
3095
|
+
|
3096
|
+
case "<->":
|
3097
|
+
return "leftrightarrow";
|
3098
|
+
|
3099
|
+
case "<-->":
|
3100
|
+
return "rightleftarrows";
|
3101
|
+
|
3102
|
+
case "<=>":
|
3103
|
+
return "rightleftharpoons";
|
3104
|
+
|
3105
|
+
case "\u21CC":
|
3106
|
+
return "rightleftharpoons";
|
3107
|
+
|
3108
|
+
case "<=>>":
|
3109
|
+
return "rightequilibrium";
|
3110
|
+
|
3111
|
+
case "<<=>":
|
3112
|
+
return "leftequilibrium";
|
3113
|
+
|
3114
|
+
default:
|
3115
|
+
assertNever(a);
|
3116
|
+
throw ["MhchemBugT", "mhchem bug T. Please report."];
|
3117
|
+
}
|
3118
|
+
},
|
3119
|
+
_getBond: function _getBond(a) {
|
3120
|
+
switch (a) {
|
3121
|
+
case "-":
|
3122
|
+
return "{-}";
|
3123
|
+
|
3124
|
+
case "1":
|
3125
|
+
return "{-}";
|
3126
|
+
|
3127
|
+
case "=":
|
3128
|
+
return "{=}";
|
3129
|
+
|
3130
|
+
case "2":
|
3131
|
+
return "{=}";
|
3132
|
+
|
3133
|
+
case "#":
|
3134
|
+
return "{\\equiv}";
|
3135
|
+
|
3136
|
+
case "3":
|
3137
|
+
return "{\\equiv}";
|
3138
|
+
|
3139
|
+
case "~":
|
3140
|
+
return "{\\tripledash}";
|
3141
|
+
|
3142
|
+
case "~-":
|
3143
|
+
return "{\\mathrlap{\\raisebox{-.1em}{$-$}}\\raisebox{.1em}{$\\tripledash$}}";
|
3144
|
+
|
3145
|
+
case "~=":
|
3146
|
+
return "{\\mathrlap{\\raisebox{-.2em}{$-$}}\\mathrlap{\\raisebox{.2em}{$\\tripledash$}}-}";
|
3147
|
+
|
3148
|
+
case "~--":
|
3149
|
+
return "{\\mathrlap{\\raisebox{-.2em}{$-$}}\\mathrlap{\\raisebox{.2em}{$\\tripledash$}}-}";
|
3150
|
+
|
3151
|
+
case "-~-":
|
3152
|
+
return "{\\mathrlap{\\raisebox{-.2em}{$-$}}\\mathrlap{\\raisebox{.2em}{$-$}}\\tripledash}";
|
3153
|
+
|
3154
|
+
case "...":
|
3155
|
+
return "{{\\cdot}{\\cdot}{\\cdot}}";
|
3156
|
+
|
3157
|
+
case "....":
|
3158
|
+
return "{{\\cdot}{\\cdot}{\\cdot}{\\cdot}}";
|
3159
|
+
|
3160
|
+
case "->":
|
3161
|
+
return "{\\rightarrow}";
|
3162
|
+
|
3163
|
+
case "<-":
|
3164
|
+
return "{\\leftarrow}";
|
3165
|
+
|
3166
|
+
case "<":
|
3167
|
+
return "{<}";
|
3168
|
+
|
3169
|
+
case ">":
|
3170
|
+
return "{>}";
|
3171
|
+
|
3172
|
+
default:
|
3173
|
+
assertNever(a);
|
3174
|
+
throw ["MhchemBugT", "mhchem bug T. Please report."];
|
3175
|
+
}
|
3176
|
+
},
|
3177
|
+
_getOperator: function _getOperator(a) {
|
3178
|
+
switch (a) {
|
3179
|
+
case "+":
|
3180
|
+
return " {}+{} ";
|
3181
|
+
|
3182
|
+
case "-":
|
3183
|
+
return " {}-{} ";
|
3184
|
+
|
3185
|
+
case "=":
|
3186
|
+
return " {}={} ";
|
3187
|
+
|
3188
|
+
case "<":
|
3189
|
+
return " {}<{} ";
|
3190
|
+
|
3191
|
+
case ">":
|
3192
|
+
return " {}>{} ";
|
3193
|
+
|
3194
|
+
case "<<":
|
3195
|
+
return " {}\\ll{} ";
|
3196
|
+
|
3197
|
+
case ">>":
|
3198
|
+
return " {}\\gg{} ";
|
3199
|
+
|
3200
|
+
case "\\pm":
|
3201
|
+
return " {}\\pm{} ";
|
3202
|
+
|
3203
|
+
case "\\approx":
|
3204
|
+
return " {}\\approx{} ";
|
3205
|
+
|
3206
|
+
case "$\\approx$":
|
3207
|
+
return " {}\\approx{} ";
|
3208
|
+
|
3209
|
+
case "v":
|
3210
|
+
return " \\downarrow{} ";
|
3211
|
+
|
3212
|
+
case "(v)":
|
3213
|
+
return " \\downarrow{} ";
|
3214
|
+
|
3215
|
+
case "^":
|
3216
|
+
return " \\uparrow{} ";
|
3217
|
+
|
3218
|
+
case "(^)":
|
3219
|
+
return " \\uparrow{} ";
|
3220
|
+
|
3221
|
+
default:
|
3222
|
+
assertNever(a);
|
3223
|
+
throw ["MhchemBugT", "mhchem bug T. Please report."];
|
3224
|
+
}
|
3225
|
+
}
|
3226
|
+
}; //
|
3227
|
+
// Helpers for code anaylsis
|
3228
|
+
// Will show type error at calling position
|
3229
|
+
//
|
3230
|
+
|
3231
|
+
/** @param {number} a */
|
3232
|
+
|
3233
|
+
function assertNever(a) {}
|
3234
|
+
/** @param {string} a */
|
3235
|
+
|
3236
|
+
|
3237
|
+
function assertString(a) {}
|
3238
|
+
|
3239
|
+
/***/ })
|
3240
|
+
/******/ ])["default"];
|
3241
|
+
});
|