fix(markdown): preserve entity for surrogate pair (#4832)
parent
85eb3b63ad
commit
cd16ff27d7
|
@ -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
|
||||
|
||||
`;
|
||||
|
|
|
@ -15,3 +15,15 @@ asd & asd „ 123
|
|||
123 * 123 * 123
|
||||
|
||||
## 类的 prototype 属性和\_\_proto\_\_属性
|
||||
|
||||
123�123
|
||||
|
||||
123#123
|
||||
|
||||
123Ϡ123
|
||||
|
||||
123😉123
|
||||
|
||||
123"123
|
||||
|
||||
123�123
|
||||
|
|
Loading…
Reference in New Issue