找回密码
 快速注册
搜索
查看: 14|回复: 1

[MathJax] 将 <mark> 标签替换为其内容

[复制链接]

3149

主题

8386

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65391
QQ

显示全部楼层

hbghlyj 发表于 2024-9-15 18:08 |阅读模式
想法:将所有方程中的 <mark> 替换为其内容
方程之外的<mark>保持不变
github.com/mathjax/MathJax/issues/3284
期待 GitHub 上的回复

3149

主题

8386

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65391
QQ

显示全部楼层

 楼主| hbghlyj 发表于 2024-9-15 20:44
我好像自己解决了这个问题
  1. <script>
  2. MathJax = {
  3.   startup: {
  4.     ready: function() {
  5.       const {HTMLDomStrings} = MathJax._.handlers.html.HTMLDomStrings;
  6.       HTMLDomStrings.OPTIONS.includeHtmlTags['mark'] = '';
  7.       var handleTag = HTMLDomStrings.prototype.handleTag;
  8.       HTMLDomStrings.prototype.handleTag = function (node, ignore) {
  9.         if (this.adaptor.kind(node) === 'mark') {
  10.           const text = this.adaptor.textContent(node);
  11.           this.snodes.push([node, text.length]);
  12.           this.string += text;
  13.         }
  14.         return handleTag.call(this, node, ignore);
  15.       }
  16.       MathJax.startup.defaultReady();
  17.     }
  18.   }
  19. };
  20. </script>
  21. <script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js"></script>
  22. <mark>x_2</mark> \(x_1+<mark>x_2</mark>+x_3\)
复制代码

手机版|悠闲数学娱乐论坛(第3版)

GMT+8, 2025-3-4 15:19

Powered by Discuz!

× 快速回复 返回顶部 返回列表