forked from cp-algorithms/cp-algorithms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.js
More file actions
65 lines (64 loc) · 2.09 KB
/
config.js
File metadata and controls
65 lines (64 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Makes text selectable
MathJax = {
addCopyText(math, doc) {
if (math.state() < MathJax.STATE.ADDTEXT) {
if (!math.isEscaped) {
const adaptor = doc.adaptor;
const text = adaptor.node('span', {'aria-hidden': true, 'class': 'mathjax_ignore mjx-copytext'}, [
adaptor.text(math.start.delim + math.math + math.end.delim)
]);
adaptor.append(math.typesetRoot, text);
// Insert thin space(s) if math is at begin or end of text
if (math.start.n == 0) {
adaptor.insert(adaptor.text('\u200A'), adaptor.firstChild(math.typesetRoot));
}
if (math.end.n == math.end.node.length) {
adaptor.append(math.typesetRoot, adaptor.text('\u200A'));
}
}
math.state(MathJax.STATE.ADDTEXT);
}
},
startup: {
ready() {
const {newState, STATE} = MathJax._.core.MathItem;
const {AbstractMathDocument} = MathJax._.core.MathDocument;
const {CHTML} = MathJax._.output.chtml_ts;
newState('ADDTEXT', 156);
AbstractMathDocument.ProcessBits.allocate('addtext');
CHTML.commonStyles['mjx-copytext'] = {
display: 'inline-block',
position: 'absolute',
top: 0, left: 0, width: 0, height: 0,
opacity: 0,
overflow: 'hidden'
};
MathJax.STATE = STATE;
MathJax.startup.defaultReady();
}
},
tex: {
inlineMath: [["$", "$"], ["\\(", "\\)"]],
displayMath: [["$$", "$$"], ["\\[", "\\]"]],
processEscapes: true,
processEnvironments: true
},
options: {
ignoreHtmlClass: ".*|",
processHtmlClass: "arithmatex",
renderActions: {
addCopyText: [156,
(doc) => {
if (!doc.processed.isSet('addtext')) {
for (const math of doc.math) MathJax.config.addCopyText(math, doc);
doc.processed.set('addtext');
}
},
(math, doc) => MathJax.config.addCopyText(math, doc)
]
}
}
}
document$.subscribe(() => {
MathJax.typesetPromise()
})