Forgot password
 Register account
View 126|Reply 1

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

[Copy link]

3175

Threads

7937

Posts

48

Reputation

Show all posts

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

3175

Threads

7937

Posts

48

Reputation

Show all posts

original poster hbghlyj posted 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\)
Copy the Code

Quick Reply

Advanced Mode
B Color Image Link Quote Code Smilies
You have to log in before you can reply Login | Register account

$\LaTeX$ formula tutorial

Mobile version

2025-7-1 03:30 GMT+8

Powered by Discuz!

Processed in 0.027679 seconds, 22 queries