Correctly format CJK sentences with Variation Selector. (#8511)

* Correctly format CJK sentences with IVS.

* Changelog pr-8511

* Changelog title should contain the title

* GitHub user name can contain `-`.

https://github.com/prettier/prettier/pull/8511#issuecomment-640231668
This commit is contained in:
さっちゃん authored and GitHub committed 2020-06-08 10:01:31 +03:00
1 parent a9fd99846a
commit 0f8cc01aa5
5 files changed
+32 -3

No files matched your search

+13
View File
@@ -0,0 +1,13 @@
#### Correctly format CJK sentences with Variation Selector ([#8511](https://github.com/prettier/prettier/pull/8511) by [@ne-sachirou](https://github.com/ne-sachirou))
<!-- prettier-ignore -->
```markdown
<!-- Input -->
麻󠄁羽󠄀‼️
<!-- Prettier stable -->
麻 󠄁 羽 󠄀 ‼️
<!-- Prettier master -->
麻󠄁羽󠄀‼️
```
+1 -1
View File
@@ -387,7 +387,7 @@
],
"ignoreRegExpList": [
"<!-- prettier-ignore -->\\n(`{3,})\\w*\\n[\\s\\S]+?\\1",
"\\[(\\*{2})?@\\w+?\\1\\]",
"\\[(\\*{2})?@[-\\w]+?\\1\\]",
"\\[`\\w+`\\]",
"ve{2,}r{2,}y",
"ve+r+y+long\\w*",
+4 -2
View File
@@ -4,7 +4,7 @@ const cjkRegex = require("cjk-regex");
const regexpUtil = require("regexp-util");
const unicodeRegex = require("unicode-regex");
const cjkPattern = cjkRegex()
const cjkPattern = `(?:${cjkRegex()
.union(
unicodeRegex({
Script_Extensions: ["Han", "Katakana", "Hiragana", "Hangul", "Bopomofo"],
@@ -18,7 +18,9 @@ const cjkPattern = cjkRegex()
],
})
)
.toString();
.toString()})(?:${unicodeRegex({
Block: ["Variation_Selectors", "Variation_Selectors_Supplement"],
}).toString()})?`;
const kPattern = unicodeRegex({ Script: ["Hangul"] })
.union(unicodeRegex({ Script_Extensions: ["Hangul"] }))
@@ -23,6 +23,8 @@ This ia an english paragraph with a CJK quote “中文“.
该网站在国外无法访问,故以下演示无效
:::
IVS 麻󠄁羽󠄀‼️
=====================================output=====================================
這是一段很長很長很長很長很長很長很長很長很長很長很長很長很長很長很長很長很長很長
很長的段落
@@ -49,6 +51,8 @@ This ia an english paragraph with a CJK quote “中文“.
::: warning 注意该网站在国外无法访问,故以下演示无效 :::
IVS 麻󠄁羽󠄀‼️
================================================================================
`;
@@ -75,6 +79,8 @@ This ia an english paragraph with a CJK quote “中文“.
该网站在国外无法访问,故以下演示无效
:::
IVS 麻󠄁羽󠄀‼️
=====================================output=====================================
這是一段很長很長很長很長很長很長很長很長很長很長很長很長很長很長很長很長很長很長很長的段落
@@ -90,6 +96,8 @@ This ia an english paragraph with a CJK quote “中文“.
::: warning 注意该网站在国外无法访问,故以下演示无效 :::
IVS 麻󠄁羽󠄀‼️
================================================================================
`;
@@ -116,6 +124,8 @@ This ia an english paragraph with a CJK quote “中文“.
该网站在国外无法访问,故以下演示无效
:::
IVS 麻󠄁羽󠄀‼️
=====================================output=====================================
這是一段很長很長很長很長很長很長很長很長很長很長很長很長很長很長很長很長很長很長很長的段落
@@ -133,6 +143,8 @@ This ia an english paragraph with a CJK quote “中文“.
该网站在国外无法访问,故以下演示无效
:::
IVS 麻󠄁羽󠄀‼️
================================================================================
`;
+2
View File
@@ -13,3 +13,5 @@ This ia an english paragraph with a CJK quote “中文“.
::: warning 注意
该网站在国外无法访问,故以下演示无效
:::
IVS 麻󠄁羽󠄀‼️