@pie-lib/math-rendering 3.2.2-next.4 → 3.3.1-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,108 +0,0 @@
1
- console.log('demo');
2
- // import { renderMath } from '../lib/index';
3
-
4
- // document.addEventListener('DOMContentLoaded', () => {
5
- // renderMath(document.querySelector('#mathml-node'));
6
- // });
7
- /*************************************************************************
8
- *
9
- * mj3-mml2html-beta.js
10
- *
11
- * Uses MathJax v3 to convert MathML to HTML within a browser page.
12
- *
13
- * ----------------------------------------------------------------------
14
- *
15
- * Copyright (c) 2018 The MathJax Consortium
16
- *
17
- * Licensed under the Apache License, Version 2.0 (the "License");
18
- * you may not use this file except in compliance with the License.
19
- * You may obtain a copy of the License at
20
- *
21
- * http://www.apache.org/licenses/LICENSE-2.0
22
- *
23
- * Unless required by applicable law or agreed to in writing, software
24
- * distributed under the License is distributed on an "AS IS" BASIS,
25
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
26
- * See the License for the specific language governing permissions and
27
- * limitations under the License.
28
- */
29
-
30
- const MathJax = require('mathjax3/mathjax3/mathjax.js').MathJax; // MathJax core
31
- const MathML = require('mathjax3/mathjax3/input/mathml.js').MathML; // MathML input
32
- const CHTML = require('mathjax3/mathjax3/output/chtml.js').CHTML; // HTML output
33
- const adaptor = require('mathjax3/mathjax3/adaptors/browserAdaptor').browserAdaptor; // browser DOM
34
- const PACKAGES = [
35
- 'action', 'ams',
36
- 'amscd', 'base',
37
- 'bbox', 'boldsymbol',
38
- 'braket', 'bussproofs',
39
- 'cancel', 'color',
40
- 'configmacros', 'enclose',
41
- 'extpfeil', 'html',
42
- 'mhchem', 'newcommand',
43
- 'noerrors', 'noundefined',
44
- 'tagformat', 'textmacros',
45
- 'unicode', 'verb'
46
- ]
47
- //
48
- // Register the HTML handler with the browser adaptor
49
- //
50
- require('mathjax3/mathjax3/handlers/html.js').RegisterHTMLHandler(adaptor());
51
-
52
- //
53
- // Get the input and output jax configurations from the user
54
- //
55
- const MathJaxConfig = window.MathJaxConfig || {};
56
-
57
- const mmlConfig = Object.assign({}, MathJaxConfig.MathML || {});
58
- const htmlConfig = Object.assign(
59
- {
60
- fontURL: 'https://cdn.rawgit.com/mathjax/mathjax-v3/3.0.0-beta.1/mathjax2/css'
61
- },
62
- MathJaxConfig.HTML || {}
63
- );
64
- const texConfig = { packages: PACKAGES, inlineMath: [['$', '$'], ['\\(', '\\)']], processEscapes: true, macros: {
65
- parallelogram: '\\lower.2em{\\Large\\unicode{x25B1}}' }
66
- //
67
- // Initialize mathjax with a DOM document.
68
- //
69
- const html = MathJax.document(document, {
70
- InputJax: [new TeX(texConfig), new MathML(mmlConfig)],
71
- OutputJax: new CHTML(htmlConfig)
72
- });
73
-
74
- //
75
- // Process the document
76
- //
77
- window.MathJax = {
78
- version: MathJax.version,
79
- html: html,
80
- Typeset: function(...elements) {
81
- this.html
82
- .findMath(elements.length ? { elements } : {})
83
- .compile()
84
- .getMetrics()
85
- .typeset()
86
- .updateDocument()
87
- .clear();
88
- }
89
- };
90
-
91
- //
92
- // Do the initial typesetting
93
- //
94
- if (!MathJaxConfig.skipInitialTypeset) {
95
- //
96
- // If the window is already loaded, just call Typeset()
97
- // Otherwise, set an event listener and run Typeset() when DOM is loaded
98
- //
99
- if (document.readyState && document.readyState !== 'loading') {
100
- window.MathJax.Typeset(...(MathJaxConfig.elements || []));
101
- } else {
102
- window.addEventListener(
103
- 'DOMContentLoaded',
104
- () => window.MathJax.Typeset(...(MathJaxConfig.elements || [])),
105
- false
106
- );
107
- }
108
- }
@@ -1,158 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <script>
5
- window.pie = window.pie || {};
6
- window.pie.mathRendering = { useSingleDollar: false };
7
- </script>
8
- <script src="./main.bundle.js"></script>
9
- </head>
10
-
11
- <body>
12
- <div id="mathml-node">
13
- <br />
14
- <span>inline: \(\frac{1}{2}\)</span>
15
- <br />
16
- block: <span>\[\frac{1}{2}\]</span>
17
- <br />
18
- <span>single dollar: $\frac{1}{2}$</span>
19
- <br />
20
- <span> double dollar: $$\frac{1}{2}$$</span>
21
- <math xmlns="http://www.w3.org/1998/Math/MathML">
22
- <mi>a</mi>
23
- <mo>&#x2260;</mo>
24
- <mn>0</mn> </math
25
- >, there are two solutions to
26
- <math xmlns="http://www.w3.org/1998/Math/MathML">
27
- <mi>ab</mi>
28
- <msup>
29
- <mi>x</mi>
30
- <mn>2</mn>
31
- </msup>
32
- <mo>+</mo>
33
- <mi>b</mi>
34
- <mi>x</mi>
35
- <mo>+</mo>
36
- <mi>c</mi>
37
- <mo>=</mo>
38
- <mn>0</mn>
39
- </math>
40
- and they are
41
- <br />
42
- <math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
43
- <mi>x</mi>
44
- <mo>=</mo>
45
- <mrow>
46
- <mfrac>
47
- <mrow>
48
- <mo>&#x2212;</mo>
49
- <mi>b</mi>
50
- <mo>&#x00B1;</mo>
51
- <msqrt>
52
- <msup>
53
- <mi>bfoo bar</mi>
54
- <mn>2</mn>
55
- </msup>
56
- <mo>&#x2212;</mo>
57
- <mn>4</mn>
58
- <mi>a</mi>
59
- <mi>c</mi>
60
- </msqrt>
61
- </mrow>
62
- <mrow>
63
- <mn>2</mn>
64
- <mi>a</mi>
65
- </mrow>
66
- </mfrac>
67
- </mrow>
68
- <mtext>.</mtext>
69
- </math>
70
-
71
- <math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
72
- <msup>
73
- <mrow>
74
- <mo>(</mo>
75
- <mrow>
76
- <munderover>
77
- <mo
78
- >&#x2211;
79
- <!-- ∑ -->
80
- </mo>
81
- <mrow class="MJX-TeXAtom-ORD">
82
- <mi>k</mi>
83
- <mo>=</mo>
84
- <mn>1</mn>
85
- </mrow>
86
- <mi>n</mi>
87
- </munderover>
88
- <msub>
89
- <mi>a</mi>
90
- <mi>k</mi>
91
- </msub>
92
- <msub>
93
- <mi>b</mi>
94
- <mi>k</mi>
95
- </msub>
96
- </mrow>
97
- <mo>)</mo>
98
- </mrow>
99
- <mrow class="MJX-TeXAtom-ORD">
100
- <mspace width="negativethinmathspace" />
101
- <mspace width="negativethinmathspace" />
102
- <mn>2</mn>
103
- </mrow>
104
- </msup>
105
- <mo
106
- >&#x2264;
107
- <!-- ≤ -->
108
- </mo>
109
- <mrow>
110
- <mo>(</mo>
111
- <mrow>
112
- <munderover>
113
- <mo
114
- >&#x2211;
115
- <!-- ∑ -->
116
- </mo>
117
- <mrow class="MJX-TeXAtom-ORD">
118
- <mi>k</mi>
119
- <mo>=</mo>
120
- <mn>1</mn>
121
- </mrow>
122
- <mi>n</mi>
123
- </munderover>
124
- <msubsup>
125
- <mi>a</mi>
126
- <mi>k</mi>
127
- <mn>2</mn>
128
- </msubsup>
129
- </mrow>
130
- <mo>)</mo>
131
- </mrow>
132
- <mrow>
133
- <mo>(</mo>
134
- <mrow>
135
- <munderover>
136
- <mo
137
- >&#x2211;
138
- <!-- ∑ -->
139
- </mo>
140
- <mrow class="MJX-TeXAtom-ORD">
141
- <mi>k</mi>
142
- <mo>=</mo>
143
- <mn>1</mn>
144
- </mrow>
145
- <mi>n</mi>
146
- </munderover>
147
- <msubsup>
148
- <mi>b</mi>
149
- <mi>k</mi>
150
- <mn>2</mn>
151
- </msubsup>
152
- </mrow>
153
- <mo>)</mo>
154
- </mrow>
155
- </math>
156
- </div>
157
- </body>
158
- </html>
@@ -1,16 +0,0 @@
1
- import renderMath from '../src/render-math';
2
-
3
- const init = () => {
4
- const mathNodes = document.querySelectorAll('div');
5
-
6
- // const node = document.querySelector('#mathml-node');
7
- renderMath(mathNodes);
8
- };
9
-
10
- if (document.readyState === 'ready') {
11
- init();
12
- } else {
13
- document.addEventListener('DOMContentLoaded', () => {
14
- init();
15
- });
16
- }
@@ -1,29 +0,0 @@
1
- const { resolve } = require('path');
2
-
3
- module.exports = {
4
- mode: 'development',
5
- module: {
6
- rules: [
7
- {
8
- test: /\.js$/,
9
- exclude: /(node_modules)/,
10
- use: {
11
- loader: 'babel-loader',
12
- options: {
13
- presets: ['env'],
14
- },
15
- },
16
- },
17
- ],
18
- },
19
- entry: {
20
- demo: './demo.js',
21
- main: './main.js',
22
- },
23
- output: {
24
- filename: '[name].bundle.js',
25
- },
26
- resolveLoader: {
27
- modules: ['node_modules', '../../../node_modules'],
28
- },
29
- };