From d8b99effa0654a51689bc0977bbeda65badb6daa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Wang?= Date: Sat, 22 Dec 2012 21:30:14 +0100 Subject: [PATCH] Follow suggestions from Davide's review comment. --- unpacked/extensions/toMathML.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/unpacked/extensions/toMathML.js b/unpacked/extensions/toMathML.js index fc156c613..cb40e66aa 100644 --- a/unpacked/extensions/toMathML.js +++ b/unpacked/extensions/toMathML.js @@ -122,10 +122,14 @@ MathJax.Hub.Register.LoadHook("[MathJax]/jax/element/mml/jax.js",function () { // Code points U+10000 to U+10FFFF. // n is the lead surrogate, let's read the trail surrogate. var trailSurrogate = string[i+1].charCodeAt(0); - var codePoint = (((n-0xD800)*0x400)+(trailSurrogate-0xDC00)+0x10000); + var codePoint = (((n-0xD800)<<10)+(trailSurrogate-0xDC00)+0x10000); string[i] = "&#x"+codePoint.toString(16).toUpperCase()+";"; string[i+1] = ""; i++; + } else { + // n is a lead surrogate without corresponding trail surrogate: + // remove that character. + string[i] = ""; } } return string.join("");