🐛 FIX: parsing of unicode ordinals (#81)
Co-authored-by: Chris Sewell <chrisj_sewell@hotmail.com>
diff --git a/markdown_it/common/utils.py b/markdown_it/common/utils.py
index 17337c3..1dcabc3 100644
--- a/markdown_it/common/utils.py
+++ b/markdown_it/common/utils.py
@@ -92,15 +92,13 @@
return True
-def fromCodePoint(c):
+def fromCodePoint(c: int) -> str:
+ """Convert ordinal to unicode.
- if c > 0xFFFF:
- c -= 0x10000
- surrogate1 = 0xD800 + (c >> 10)
- surrogate2 = 0xDC00 + (c & 0x3FF)
-
- return "".join(map(chr, [surrogate1, surrogate2]))
-
+ Note, in the original Javascript two string characters were required,
+ for codepoints larger than `0xFFFF`.
+ But Python 3 can represent any unicode codepoint in one character.
+ """
return chr(c)
diff --git a/tests/test_port/fixtures/issue-fixes.md b/tests/test_port/fixtures/issue-fixes.md
index 562d340..0c693b0 100644
--- a/tests/test_port/fixtures/issue-fixes.md
+++ b/tests/test_port/fixtures/issue-fixes.md
@@ -29,3 +29,10 @@
<p>Another Block Quote</p>
</blockquote>
.
+
+#80 UnicodeError with codepoints larger than 0xFFFF
+.
+💬
+.
+<p>💬</p>
+.