Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wordpress html发布时公式无法显示 #822

Closed
lisontowind opened this issue Oct 21, 2023 · 1 comment
Closed

wordpress html发布时公式无法显示 #822

lisontowind opened this issue Oct 21, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@lisontowind
Copy link

wordpress html发布的时候公式无法显示
如图:
image
还是希望作者大大改善一下!
我的解决方案:

  1. 安装 simple mathjax插件
  2. 安装Custom JavaScript插件并替换掉html代码
// 选择所有类为 "language-math" 的 div 元素
var mathDivs = document.querySelectorAll('div.language-math');

// 遍历每个 div 元素
mathDivs.forEach(function(mathDiv) {
    // 获取当前文本内容
    var currentText = mathDiv.innerText;

    // 在文本前后添加 $$
    var newText = '$$' + currentText + '$$';

    // 将新文本设置回 div 元素
    mathDiv.innerText = newText;
});

// 选择所有类为 "language-math" 的 span 元素
var mathSpans = document.querySelectorAll('span.language-math');

// 遍历每个 span 元素
mathSpans.forEach(function(mathSpan) {
    // 获取当前文本内容
    var currentText = mathSpan.innerText;

    // 在文本前后添加 $$
    var newText = '$' + currentText + '$';

    // 将新文本设置回 span 元素
    mathSpan.innerText = newText;
});

然后渲染好了:
image

@terwer terwer added the enhancement New feature or request label Oct 22, 2023
@terwer
Copy link
Owner

terwer commented Oct 28, 2023

步骤2已经内置支持,请升级 1.18.0

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants