cmark

My personal build of CMark ✏️

Commit
3fa0714153aa2242868d29a0c6e2816e561fbfbd
Parent
c507d164f5856779d23ef030c2a656391707a5ac
Author
John MacFarlane <jgm@berkeley.edu>
Date

Merge pull request #203 from gcrico/Issue-202

Fix Issue 202 - Catch RangeError thrown by native String.fromCodePoint (js)

Diffstat

1 file changed, 10 insertions, 1 deletion

Status File Name N° Changes Insertions Deletions
Modified js/lib/from-code-point.js 11 10 1
diff --git a/js/lib/from-code-point.js b/js/lib/from-code-point.js
@@ -2,7 +2,16 @@
 /*! http://mths.be/fromcodepoint v0.2.1 by @mathias */
 if (String.fromCodePoint) {
 
-  module.exports = String.fromCodePoint;
+    module.exports = function (_) {
+        try {
+            return String.fromCodePoint(_);
+        } catch (e) {
+            if (e instanceof RangeError) {
+                return String.fromCharCode(0xFFFD);
+            }
+            throw e;
+        }
+    }
 
 } else {