Forgot password
 Register account
View 1099|Reply 3

恢复公式代码

[Copy link]

3175

Threads

7936

Posts

48

Reputation

Show all posts

hbghlyj posted 2024-1-18 20:22 |Read mode
Last edited by hbghlyj 2025-4-6 07:15
  1. MathJax.startup.document.removeFromDocument(true)
Copy the Code

Rate

Number of participants 1威望 +2 Collapse Reason
uk702 + 2 很有用!

View Rating Log

678

Threads

110K

Posts

213

Reputation

Show all posts

kuing posted 2024-1-18 22:56
哦,试了一下,在控制台运行它,整个页面的公式变回代码😀那可以做成一个按钮来切换。

不过代码的换行似乎全没了,还是点右上角那眼比较好阅读😊

Comment

老大大创举!赶快申请专利啊。  posted 2024-1-22 09:38

3175

Threads

7936

Posts

48

Reputation

Show all posts

original poster hbghlyj posted 2025-4-2 23:21

v2

如StackExchange使用MathJax v2,
根据google group mathjax-users帖子,
  1. var jax = MathJax.Hub.getAllJax();
  2. for (var i = 0, m = jax.length; i < m; i++) {
  3.   var tex = jax[i].originalText;
  4.   var isDisplay = (jax[i].root.Get("display") === "block");
  5.   if (isDisplay) tex = "$$"+tex+"$$"; else tex = "$"+tex+"$";
  6.   var script = jax[i].SourceElement();
  7.   jax[i].Remove();
  8.   var preview = script.previousSibling;
  9.   if (preview && preview.className === "MathJax_Preview")
  10.     preview.parentNode.removeChild(preview);
  11.   script.parentNode.insertBefore(document.createTextNode(tex),script);
  12.   script.parentNode.removeChild(script);
  13. }
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-2 07:48 GMT+8

Powered by Discuz!

Processed in 0.015610 seconds, 32 queries