|
Davide Cervone曾经写过:将隐藏文本附加到 MathJax 输出,该文本包含原始 TeX 代码,选择公式时将选择该文本,来代替 MathJax 输出就像它没有排版一样。
- MathJax = {
- options: {
- renderActions: {
- addCopyText: [155,
- (doc) => {for (const math of doc.math) MathJax.config.addCopyText(math, doc)},
- (math, doc) => MathJax.config.addCopyText(math, doc)
- ]
- }
- },
- addCopyText(math, doc) {
- const adaptor = doc.adaptor;
- const text = adaptor.node('mjx-copytext', {'aria-hidden': true}, [
- adaptor.text(math.start.delim + math.math + math.end.delim)
- ]);
- adaptor.append(math.typesetRoot, text);
- },
- startup: {
- ready() {
- MathJax._.output.chtml_ts.CHTML.commonStyles['mjx-copytext'] = {
- display: 'inline-block',
- position: 'absolute',
- top: 0, left: 0, width: 0, height: 0,
- opacity: 0,
- overflow: 'hidden'
- };
- MathJax.startup.defaultReady();
- }
- }
- }
复制代码 |
|