Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(markdown): identify CJK correctly #5402

Merged
merged 2 commits into from Nov 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 17 additions & 2 deletions src/language-markdown/constants.evaluate.js
Expand Up @@ -4,8 +4,23 @@ const cjkRegex = require("cjk-regex");
const regexpUtil = require("regexp-util");
const unicodeRegex = require("unicode-regex");

const cjkPattern = cjkRegex().toString();
const kPattern = unicodeRegex({ Script: ["Hangul"] }).toString();
const cjkPattern = cjkRegex()
.union(
unicodeRegex({
Script_Extensions: ["Han", "Katakana", "Hiragana", "Hangul", "Bopomofo"],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Bopomofo"

I love this name 😆

General_Category: [
"Other_Letter",
"Letter_Number",
"Other_Symbol",
"Modifier_Letter"
]
})
)
.toString();

const kPattern = unicodeRegex({ Script: ["Hangul"] })
.union(unicodeRegex({ Script_Extensions: ["Hangul"] }))
.toString();

// http://spec.commonmark.org/0.25/#ascii-punctuation-character
const asciiPunctuationCharset = /* prettier-ignore */ regexpUtil.charset(
Expand Down
4 changes: 4 additions & 0 deletions tests/markdown_splitCjkText/__snapshots__/jsfmt.spec.js.snap
Expand Up @@ -6,6 +6,8 @@ exports[`chinese-japanese.md - markdown-verify 1`] = `
全  形 空白全  形 空白全  形 空白全  形 空白全  形 空白全  形 空白全  形 空白

空白全形空白全形空白全形空白 空白全形空白全形空白全形空白 空白全形空白全形空白全形空白 空白全形空白全形空白全形空白

何でも薄暗いじめじめした所でニャーニャー泣いていた事だけは記憶している。
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
這是一段很長很長很長很長很長很長很長很長很長很長很長很長很長很長很長很長很長很長
很長的段落
Expand All @@ -16,6 +18,8 @@ exports[`chinese-japanese.md - markdown-verify 1`] = `
空白全形空白全形空白全形空白 空白全形空白全形空白全形空白 空白全形空白全形空白
全形空白 空白全形空白全形空白全形空白

何でも薄暗いじめじめした所でニャーニャー泣いていた事だけは記憶している。

`;

exports[`korean.md - markdown-verify 1`] = `
Expand Down
2 changes: 2 additions & 0 deletions tests/markdown_splitCjkText/chinese-japanese.md
Expand Up @@ -3,3 +3,5 @@
全  形 空白全  形 空白全  形 空白全  形 空白全  形 空白全  形 空白全  形 空白

空白全形空白全形空白全形空白 空白全形空白全形空白全形空白 空白全形空白全形空白全形空白 空白全形空白全形空白全形空白

何でも薄暗いじめじめした所でニャーニャー泣いていた事だけは記憶している。