XML-escape TeX annotation

This commit is contained in:
physikerwelt (Moritz Schubotz) 2014-10-14 18:34:36 +02:00
parent 9cefee80f9
commit c526b2a5c5

View File

@ -160,7 +160,10 @@ MathJax.Hub.Register.LoadHook("[MathJax]/jax/element/mml/jax.js",function () {
if (annotation) {
if (nested) {data.unshift(space+" <mrow>"); data.push(space+" </mrow>")}
data.unshift(space+" <semantics>");
data.push(space+' <annotation encoding="'+annotation+'">'+jax.originalText+"</annotation>");
var xmlEscapedTex = jax.originalText.replace(/([&<>])/g, function(item) {
return { '>': '&gt;', '<': '&lt;','&': '&amp;' }[item]
});
data.push(space+' <annotation encoding="'+annotation+'">'+xmlEscapedTex+"</annotation>");
data.push(space+" </semantics>");
}
return space+"<"+tag+attr+">\n"+data.join("\n")+"\n"+space+"</"+tag+">";