Commit b3d8abeb authored by chris's avatar chris
Browse files

mathjax test

parent 6ab7e7db
......@@ -17,10 +17,18 @@
"typeface-fira-sans-condensed": "^0.0.54",
"typeface-inter": "^1.1.13",
"typeface-vollkorn": "^0.0.54",
<<<<<<< HEAD
"wax-prosemirror-components": "^0.0.50",
"wax-prosemirror-core": "^0.0.50",
"wax-prosemirror-plugins": "^0.0.50",
"wax-prosemirror-services": "^0.0.50"
=======
"wax-prosemirror-components": "0.0.47",
"wax-prosemirror-core": "0.0.47",
"wax-prosemirror-plugins": "0.0.47",
"wax-prosemirror-services": "0.0.47",
"mathjax-full": "3.1.4"
>>>>>>> mathjax test
},
"scripts": {
"start": "react-app-rewired start",
......
......@@ -68,5 +68,8 @@
"style-loader": "^0.23.1",
"styled-components": "^5.3.0",
"svg-inline-loader": "^0.8.0"
},
"dependencies": {
"mathjax": "^3.1.4"
}
}
......@@ -11,6 +11,19 @@ import {
// katex
import katex, { ParseError } from 'katex';
import { collapseMathCmd } from './helpers/collapse-math-cmd';
import { mathjax } from 'mathjax-full/js/mathjax';
import { MathML } from 'mathjax-full/js/input/mathml';
import { SVG } from 'mathjax-full/js/output/svg';
// const { liteAdaptor } = require('mathjax-full/js/adaptors/liteAdaptor.js');
import { browserAdaptor } from 'mathjax-full/js/adaptors/browserAdaptor';
import { RegisterHTMLHandler } from 'mathjax-full/js/handlers/html';
import { STATE } from 'mathjax-full/js/core/MathItem';
const adaptor = browserAdaptor();
RegisterHTMLHandler(adaptor);
console.log(mathjax);
const mathml = new MathML({});
const svg = new SVG({ fontCache: 'none' });
const markErrors = [STATE.TYPESET + 1, null];
export class MathView {
// == Lifecycle ===================================== //
......@@ -162,19 +175,24 @@ export class MathView {
this.dom.classList.remove('empty-math');
}
// render katex, but fail gracefully
try {
katex.render(texString, this._mathRenderElt, this._katexOptions);
this._mathRenderElt.classList.remove('parse-error');
this.dom.setAttribute('title', '');
} catch (err) {
if (err instanceof ParseError) {
console.error(err);
this._mathRenderElt.classList.add('parse-error');
this.dom.setAttribute('title', err.toString());
} else {
throw err;
}
}
const mathml_html = mathjax.document('', {
InputJax: mathml,
OutputJax: svg,
renderActions: {},
});
console.log(mathml_html);
let html = mathml_html;
const math = texString;
const display = true;
// const metrics = svg.getMetricsFor(node, ture);
const outerHTML = adaptor.outerHTML(
html.convert(math, {
display,
}),
);
console.log(outerHTML);
this._mathRenderElt.innerHTML = outerHTML;
}
// == Inner Editor ================================== //
dispatchInner(tr) {
......
......@@ -5846,6 +5846,11 @@ commander@2.9.0:
dependencies:
graceful-readlink ">= 1.0.0"
 
commander@>=7.0.0:
version "7.2.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-7.2.0.tgz#a36cb57d0b501ce108e4d20559a150a391d97ab7"
integrity sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==
commander@^2.11.0, commander@^2.19.0, commander@^2.20.0:
version "2.20.3"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33"
......@@ -7941,6 +7946,11 @@ eslint@^6.6.0, eslint@^6.8.0:
text-table "^0.2.0"
v8-compile-cache "^2.0.3"
 
esm@^3.2.25:
version "3.2.25"
resolved "https://registry.yarnpkg.com/esm/-/esm-3.2.25.tgz#342c18c29d56157688ba5ce31f8431fbb795cc10"
integrity sha512-U1suiZ2oDVWv4zPO56S0NcR5QriEahGtdN2OR6FiOG4WJvcjBVFB0qI4+eKoWFH483PKGuLuu6V8Z4T5g63UVA==
espree@^6.1.2:
version "6.2.1"
resolved "https://registry.yarnpkg.com/espree/-/espree-6.2.1.tgz#77fc72e1fd744a2052c20f38a5b575832e82734a"
......@@ -11983,6 +11993,20 @@ math-expression-evaluator@^1.2.14:
resolved "https://registry.yarnpkg.com/math-expression-evaluator/-/math-expression-evaluator-1.2.22.tgz#c14dcb3d8b4d150e5dcea9c68c8dad80309b0d5e"
integrity sha512-L0j0tFVZBQQLeEjmWOvDLoRciIY8gQGWahvkztXUal8jH8R5Rlqo9GCvgqvXcy9LQhEWdQCVvzqAbxgYNt4blQ==
 
mathjax-full@3.1.4:
version "3.1.4"
resolved "https://registry.yarnpkg.com/mathjax-full/-/mathjax-full-3.1.4.tgz#ec9c51abf55b427e0fd54760ca9478d439406e59"
integrity sha512-80lZZci7vqQQV2wdLcnFUtI7z5Aru0RL03wPw8JM6kFPmX4CA/SYfnlQQ1WIIBU+0p0YoxJ6Z3gAUcVzvDArhw==
dependencies:
esm "^3.2.25"
mj-context-menu "^0.6.1"
speech-rule-engine "^3.2.0"
mathjax@^3.1.4:
version "3.1.4"
resolved "https://registry.yarnpkg.com/mathjax/-/mathjax-3.1.4.tgz#4e8932d12845c0abae8b7f1976ea98cb505e8420"
integrity sha512-Okmc+F3l7vRWNMALbH0HMMoTJWVn1cbeDbybHppCeophIGdFS+xxD/OffYpZirUOHzesZostpzEwsLSst+4W8w==
mathml-tag-names@^2.1.3:
version "2.1.3"
resolved "https://registry.yarnpkg.com/mathml-tag-names/-/mathml-tag-names-2.1.3.tgz#4ddadd67308e780cf16a47685878ee27b736a0a3"
......@@ -12456,6 +12480,11 @@ mixin-object@^2.0.1:
for-in "^0.1.3"
is-extendable "^0.1.1"
 
mj-context-menu@^0.6.1:
version "0.6.1"
resolved "https://registry.yarnpkg.com/mj-context-menu/-/mj-context-menu-0.6.1.tgz#a043c5282bf7e1cf3821de07b13525ca6f85aa69"
integrity sha512-7NO5s6n10TIV96d4g2uDpG7ZDpIhMh0QNfGdJw/W47JswFcosz457wqz/b5sAKvl12sxINGFCn80NZHKwxQEXA==
mkdirp@0.5.1:
version "0.5.1"
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903"
......@@ -17202,6 +17231,15 @@ specificity@^0.4.1:
resolved "https://registry.yarnpkg.com/specificity/-/specificity-0.4.1.tgz#aab5e645012db08ba182e151165738d00887b019"
integrity sha512-1klA3Gi5PD1Wv9Q0wUoOQN1IWAuPu0D1U03ThXTr0cJ20+/iq2tHSDnK7Kk/0LXJ1ztUB2/1Os0wKmfyNgUQfg==
 
speech-rule-engine@^3.2.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/speech-rule-engine/-/speech-rule-engine-3.2.0.tgz#6313ae0f8596519fa8dfc3ef01beae6b6cca312f"
integrity sha512-Vg1pNhl3cdVPk5XWn8su+bUNs+jaY1UmvKLeLui+iJ5/a0Kr7cOfO2gGuYOMd/3+0wLvzEqmou8rtz5REBd9xQ==
dependencies:
commander ">=7.0.0"
wicked-good-xpath "^1.3.0"
xmldom-sre "^0.1.31"
split-string@^3.0.1, split-string@^3.0.2:
version "3.1.0"
resolved "https://registry.yarnpkg.com/split-string/-/split-string-3.1.0.tgz#7cb09dda3a86585705c64b39a6466038682e8fe2"
......@@ -19172,6 +19210,11 @@ which@^2.0.1, which@^2.0.2:
dependencies:
isexe "^2.0.0"
 
wicked-good-xpath@^1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/wicked-good-xpath/-/wicked-good-xpath-1.3.0.tgz#81b0e95e8650e49c94b22298fff8686b5553cf6c"
integrity sha1-gbDpXoZQ5JyUsiKY//hoa1VTz2w=
wide-align@^1.1.0:
version "1.1.3"
resolved "https://registry.yarnpkg.com/wide-align/-/wide-align-1.1.3.tgz#ae074e6bdc0c14a431e804e624549c633b000457"
......@@ -19473,6 +19516,11 @@ xmlchars@^2.1.1:
resolved "https://registry.yarnpkg.com/xmlchars/-/xmlchars-2.2.0.tgz#060fe1bcb7f9c76fe2a17db86a9bc3ab894210cb"
integrity sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==
 
xmldom-sre@^0.1.31:
version "0.1.31"
resolved "https://registry.yarnpkg.com/xmldom-sre/-/xmldom-sre-0.1.31.tgz#10860d5bab2c603144597d04bf2c4980e98067f4"
integrity sha512-f9s+fUkX04BxQf+7mMWAp5zk61pciie+fFLC9hX9UVvCeJQfNHRHXpeo5MPcR0EUf57PYLdt+ZO4f3Ipk2oZUw==
xregexp@^4.3.0:
version "4.3.0"
resolved "https://registry.yarnpkg.com/xregexp/-/xregexp-4.3.0.tgz#7e92e73d9174a99a59743f67a4ce879a04b5ae50"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment