javascript - 阻止 mathjax 自行运行
问题描述
我正在使用mathjax3.1.2
标签。但是,我发现它在文档加载时自动运行并搞砸了我的页面,因为我有等待首先呈现的纯文本。async
script
marked.js
这是html内容:
equation_app.addEventListener('click', e=>{
autofocus(e);
let start = editor.selectionStart;
let end = editor.selectionEnd;
tagging('$', '$');
editor.focus();
if(editor.selectionStart === editor.selectionEnd)editor.selectionStart = editor.selectionEnd = start + 1;
refresh();
});
在标记渲染后,它将被包装到一个<pre>
and<code>
标签中。但是当 MathJax 在它之前运行时,它被搞砸了:
equation_app.addEventListener('click', e=>{
autofocus(e);
let start = editor.selectionStart;
let end = editor.selectionEnd;
tagging('<mjx-container class="MathJax CtxtMenu_Attached_0" jax="CHTML" role="presentation" tabindex="0" ctxtmenu_counter="0" style="font-size: 101.6%; position: relative;"><mjx-math class="MJX-TEX" aria-hidden="true"><mjx-msup><mjx-mi class="mjx-n"></mjx-mi><mjx-script style="vertical-align: 0.363em;"><mjx-mo class="mjx-n" size="s"><mjx-c class="mjx-c2032"></mjx-c></mjx-mo></mjx-script></mjx-msup><mjx-msup><mjx-mo class="mjx-n"><mjx-c class="mjx-c2C"></mjx-c></mjx-mo><mjx-script style="vertical-align: 0.363em;"><mjx-mo class="mjx-n" size="s"><mjx-c class="mjx-c2032"></mjx-c></mjx-mo></mjx-script></mjx-msup></mjx-math><mjx-assistive-mml role="presentation" unselectable="on" display="inline"><math xmlns="http://www.w3.org/1998/Math/MathML"><msup><mi></mi><mo>′</mo></msup><msup><mo>,</mo><mo>′</mo></msup></math></mjx-assistive-mml></mjx-container>');
editor.focus();
if(editor.selectionStart === editor.selectionEnd)editor.selectionStart = editor.selectionEnd = start + 1;
refresh();
});
我做了很多研究,似乎在版本 2 中skipStartupTypeset
配置解决了问题,但在版本 3 中删除了。
参考4年前的这篇文章:如何触发MathJax?
我寻求一种方法:
- 在加载时禁用 mathjax 自身运行
解决方案
通过在配置中设置以下内容,只需将 Mathjax 3 配置为在启动时不进行排版:
{
startup: {
typeset: false
}
}
文档:https ://docs.mathjax.org/en/latest/options/startup/startup.html#the-configuration-block
推荐阅读
- r - as.POSIXct 将一小段时间变成一堆数字
- java - JSP Spring Boot 在从 IntelliJ 运行时工作,但在运行 WAR 时为空页面
- amazon-web-services - Terraform 输出:错误:模块“rds”:“monitoring_role_arn”不是有效参数
- django - 无法将项目部署到 Google Cloud App Engine Standard
- sql - 在 PySpark SQL 中返回所有空值的列的总和
- java - 在使用springboot optaplanner-spring-boot-starter时,我们如何使用多个ConstraintProviders
- rundeck - 运行甲板;需要换IP
- node.js - 浏览器刷新时重新连接套接字连接
- javascript - 按字符串类型的多个属性对对象数组进行排序
- node.js - 创建自己的记录器功能