jquery - 如何将堆栈设置为mathjax?
问题描述
我想将堆栈的表达式设置为 mathjax(动态)
这是我的堆栈
var showStack=[];
showStack.push({
Key: 'topic',
Value:"سرمایه"
});
showStack.push({
Key: 'operator',
Value: "+"
});
showStack.push({
Key: 'topic',
Value: "مالیات"
});
showStack.push({
Key: 'opeator',
Value: "/"
});
showStack.push({
Key: 'number',
Value: "8569"
});
showStack.push({
Key: 'opeator',
Value: "-"
});
showStack.push({
Key: 'topic',
Value: "اندوخته قانونی - سال قبل"
});
这段代码从我的堆栈中创建我的公式
jQuery.each( showStack, function( i, val ) {
if(val.Key=='topic'){
text+='`\\text{'+ val.Value+'}`';
}
else
text+=val.Value;
});
createFormula 用于创建 mathjax 公式
function createFormula() {
var text="";
MathJax.Hub.Config({
"HTML-CSS": { mtextFontInherit: true }
});
document.querySelector('#formula').textContent =text;
MathJax.Hub.Queue(["Typeset",MathJax.Hub,'formula']);
}
但结果是
سرمایه+مالیات/8569-اندوخته قانونی - سال قبل
我的代码不起作用,我的问题在哪里?谢谢
解决方案
You just have to change this code
var text="";
jQuery.each( showStack, function( i, val ) {
if(val.Key=='topic'){
text+='\\text{'+ val.Value+'}'; // remove `
}
else
text+=val.Value;
});
And add this code
var value='`'+text+'`';
document.querySelector('#formula').textContent =value;
MathJax.Hub.Queue(["Typeset",MathJax.Hub,'formula']);
推荐阅读
- angular6 - 使用反应式 FormGroup 或 FormControlName 设置 angular6 选择选项的值
- r - 如何根据R中另一个数据帧中的值删除一个数据帧的特定记录
- c# - 从 Active Directory 进行身份验证,但从 MVC 中的 SQL 数据库授权角色
- xmlhttprequest - 多部分表单数据 POST 请求在赛普拉斯对我来说不起作用
- visual-studio-2017 - 你在哪里设置 VS2017 的默认设置?
- java - 使用 Spring Boot RestTemplate 处理异步调用
- reactjs - Semantic TextArea 无法使用初始文本进行编辑
- angular - 下拉搜索问题
- java - 与实习生的字符串比较
- powershell - 术语“System.DefaultWorkingDirectory”未被识别为 cmdlet 的名称