1.公式编辑器输出 '<' 会 'undefined'
在解析LaTeX过程中,会过滤html并且转换成为root节点
/umeditor/_src/plugins/inserthtml.js
/umeditor/_src/core/htmlparser.js
这里是通过正则表达式来过滤分析节点的,造成数据变成了
<</span>
解决方法:
思路是就不动正则表达式了,可以从其他地方解决,因为这个js是单独处理表达式的,目前只有<这个存在undefined问题
\umeditor\_src\plugins\formula.js
21行:
me.addInputRule(function (root) {
$.each(root.getNodesByTagName('span'), function (i, node) {
if (node.hasClass('mathquill-embedded-latex')) {
var firstChild, latex = '';
while(firstChild = node.firstChild()){
latex += firstChild.data;
if(latex == undefined || latex == "undefined"){
latex = "<";
}
node.removeChild(firstChild);
}
node.tagName = 'iframe';
node.setAttr({
'frameborder': '0',
'src': me.getOpt('UMEDITOR_HOME_URL') + 'dialogs/formula/formula.html',
'data-latex': utils.unhtml(latex)
});
}
});
});
2.这两个符号对应的公式是:\nsubseteq 和 \nsupseteq
在编辑器中第一次输入是正确的,可是一旦保存后,被转译成 \not\subseteq 和 \not\supseteq ,显示也变成了
原因是因为在
umeditor\dialogs\formula\formula.html
166 行 修改源码
updateIframe: function(){
$iframe.width(this.$mathquill.width()+8).height(this.$mathquill.height()+8);
var latex = $iframe.attr('data-latex'),
// 页面写入时,对公式进行校验,在\nsubseteq被编译后就变成了 \not\subseteq
newLatex = this.getLatex();
// 检验了不相等,进行重新编译 除了出问题的两个符号
if(latex != '\\nsubseteq' && latex != '\\nsupseteq' ){
if(latex != newLatex) {
$iframe.attr('data-latex', this.getLatex());
saveScene();
}
}
},
197 行 修改源码
getLatex: function(){
var mqLax = this.$mathquill.mathquill('latex');
mqLax = mqLax.replace("\\not\\subseteq","\\nsubseteq");
mqLax = mqLax.replace("\\not\\supseteq","\\nsupseteq");
return mqLax;
},