fix(markdown): preserve entity for surrogate pair (#4832)

This commit is contained in:
Ika authored and GitHub committed 2018-07-12 21:42:39 +08:00
1 parent 85eb3b63ad
commit cd16ff27d7
3 files changed
+42 -2

No files matched your search

+6 -2
View File
@@ -6,6 +6,9 @@ const pragma = require("./pragma");
const parseFrontMatter = require("../utils/front-matter");
const util = require("../common/util");
// 0x0 ~ 0x10ffff
const isSingleCharRegex = /^([\u0000-\uffff]|[\ud800-\udbff][\udc00-\udfff])$/;
/**
* based on [MDAST](https://github.com/syntax-tree/mdast) with following modifications:
*
@@ -66,8 +69,9 @@ function restoreUnescapedCharacter(originalText) {
value:
node.value !== "*" &&
node.value !== "_" && // handle these two cases in printer
node.value.length === 1 &&
node.position.end.offset - node.position.start.offset > 1
isSingleCharRegex.test(node.value) &&
node.position.end.offset - node.position.start.offset !==
node.value.length
? originalText.slice(
node.position.start.offset,
node.position.end.offset
@@ -18,6 +18,18 @@ asd & asd „ 123
123 * 123 * 123
## 类的 prototype 属性和\\_\\_proto\\_\\_属性
123�123
123#123
123Ϡ123
123😉123
123"123
123�123
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
hello \\* world \\_ ~~ ya
@@ -37,4 +49,16 @@ asd & asd „ 123
## 类的 prototype 属性和\\_\\_proto\\_\\_属性
123�123
123#123
123Ϡ123
123😉123
123"123
123�123
`;
+12
View File
@@ -15,3 +15,15 @@ asd & asd „ 123
123 * 123 * 123
## 类的 prototype 属性和\_\_proto\_\_属性
123�123
123#123
123Ϡ123
123😉123
123"123
123�123