Forgot password?
 Create new account
View 85|Reply 1

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

[Copy link]

3146

Threads

8493

Posts

610K

Credits

Credits
66158
QQ

Show all posts

hbghlyj Posted at 2024-9-15 18:08:34 |Read mode
想法:将所有方程中的 <mark> 替换为其内容
方程之外的<mark>保持不变
github.com/mathjax/MathJax/issues/3284
期待 GitHub 上的回复

3146

Threads

8493

Posts

610K

Credits

Credits
66158
QQ

Show all posts

 Author| hbghlyj Posted at 2024-9-15 20:44:02
我好像自己解决了这个问题
  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\)
Copy the Code

手机版Mobile version|Leisure Math Forum

2025-4-20 22:09 GMT+8

Powered by Discuz!

× Quick Reply To Top Return to the list