Skip to content

Commit 3a242d9

Browse files
Oleksandr Kulkovadamant-pwn
authored andcommitted
Update config.js
1 parent 5c55aa3 commit 3a242d9

1 file changed

Lines changed: 78 additions & 11 deletions

File tree

src/javascript/config.js

Lines changed: 78 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,83 @@
1-
MathJax.Hub.Config({
2-
config: ["MMLorHTML.js"],
3-
extensions: ["tex2jax.js"],
4-
jax: ["input/TeX", "output/HTML-CSS", "output/NativeMML"],
5-
tex2jax: {
6-
inlineMath: [ ["\\(","\\)"] ],
7-
displayMath: [ ["\\[","\\]"] ],
1+
// Makes text selectable
2+
MathJax = {
3+
startup: {
4+
ready() {
5+
const {TeXFont} = MathJax._.output.chtml.fonts.tex_ts;
6+
const {CHTMLFontData} = MathJax._.output.chtml.FontData;
7+
const {CHTMLTextNode} = MathJax._.output.chtml.Wrappers.TextNode;
8+
9+
for (const name of Object.keys(TeXFont.defaultChars)) {
10+
var chars = TeXFont.defaultChars[name];
11+
for (const n of Object.keys(chars)) {
12+
const options = chars[n][3];
13+
if (options && options.c) {
14+
options.c = options.c.replace(/\\[0-9A-F]+/ig, (x) => String.fromCodePoint(parseInt(x.substr(1), 16)));
15+
} else if (options) {
16+
options.c = String.fromCodePoint(parseInt(n));
17+
} else {
18+
chars[n][3] = {c: String.fromCodePoint(parseInt(n))};
19+
}
20+
}
21+
};
22+
delete TeXFont.defaultStyles['mjx-c::before'];
23+
24+
CHTMLFontData.prototype.addCharStyles = function (styles, vclass, n, data, charUsed) {
25+
const options = data[3];
26+
const letter = (options.f !== undefined ? options.f : vletter);
27+
const selector = 'mjx-c' + this.charSelector(n) + (letter ? '.TEX-' + letter : '');
28+
styles[selector + '::before'] = {padding: this.padding(data, 0, options.ic || 0)};
29+
};
30+
31+
CHTMLTextNode.prototype.toCHTML = function (parent) {
32+
this.markUsed();
33+
const adaptor = this.adaptor;
34+
const variant = this.parent.variant;
35+
const text = this.node.getText();
36+
if (variant === '-explicitFont') {
37+
adaptor.append(parent, this.jax.unknownText(text, variant, this.getBBox().w));
38+
} else {
39+
let utext = '';
40+
const chars = this.remappedText(text, variant);
41+
for (const n of chars) {
42+
const data = this.getVariantChar(variant, n)[3];
43+
if (data.unknown) {
44+
utext += String.fromCodePoint(n);
45+
} else {
46+
utext = this.addUtext(utext, variant, parent);
47+
const font = (data.f ? ' TEX-' + data.f : '');
48+
adaptor.append(parent, this.html('mjx-c', {class: this.char(n) + font}, [
49+
this.text(data.c || String.fromCodePoint(n))
50+
]));
51+
this.font.charUsage.add([variant, n]);
52+
}
53+
}
54+
this.addUtext(utext, variant, parent);
55+
}
56+
};
57+
CHTMLTextNode.prototype.addUtext = function (utext, variant, parent) {
58+
if (utext) {
59+
this.adaptor.append(parent, this.jax.unknownText(utext, variant));
60+
}
61+
return '';
62+
};
63+
64+
MathJax.startup.defaultReady();
65+
}
66+
}
67+
}
68+
69+
window.MathJax = {
70+
tex: {
71+
inlineMath: [["\\(", "\\)"]],
72+
displayMath: [["\\[", "\\]"]],
873
processEscapes: true,
9-
processEnvironments: true,
10-
ignoreClass: ".*|",
11-
processClass: "arithmatex"
74+
processEnvironments: true
1275
},
13-
});
76+
options: {
77+
ignoreHtmlClass: ".*|",
78+
processHtmlClass: "arithmatex"
79+
}
80+
};
1481

1582
document$.subscribe(() => {
1683
MathJax.typesetPromise()

0 commit comments

Comments
 (0)