Skip to content

Commit

Permalink
Revert "Revert "Switch kRegex to use RegExp with u directly"" (#1…
Browse files Browse the repository at this point in the history
…5644)

* Revert "Revert "Switch `kRegex` to use RegExp with `u` directly" (#15643)"

This reverts commit 52375f5.
  • Loading branch information
fisker committed Jun 14, 2024
1 parent 57253de commit ccde7ca
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
4 changes: 4 additions & 0 deletions scripts/build/build-javascript-module.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,10 @@ function getEsbuildOptions({ file, files, shouldCollectLicenses, cliOptions }) {
outfile: path.join(DIST_DIR, cliOptions.saveAs ?? file.output.file),
// https://esbuild.github.io/api/#main-fields
mainFields: file.platform === "node" ? ["module", "main"] : undefined,
supported: {
// https://github.com/evanw/esbuild/issues/3471
"regexp-unicode-property-escapes": true,
},
};

if (file.platform === "universal") {
Expand Down
7 changes: 1 addition & 6 deletions src/language-markdown/constants.evaluate.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ const CJK_REGEXP = new RegExp(
`(?:${cjkCharset.toString()})(?:${variationSelectorsCharset.toString()})?`,
);

const K_REGEXP = new Charset(
unicodeRegex({ Script: ["Hangul"] }),
unicodeRegex({ Script_Extensions: ["Hangul"] }),
).toRegExp();

// http://spec.commonmark.org/0.25/#ascii-punctuation-character
const asciiPunctuationCharset =
/* prettier-ignore */ new Charset(
Expand Down Expand Up @@ -57,4 +52,4 @@ const PUNCTUATION_REGEXP = new Charset(
unicodePunctuationCharset,
).toRegExp();

export { CJK_REGEXP, K_REGEXP, PUNCTUATION_REGEXP };
export { CJK_REGEXP, PUNCTUATION_REGEXP };
8 changes: 3 additions & 5 deletions src/language-markdown/utils.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import assert from "node:assert";

import {
CJK_REGEXP,
K_REGEXP,
PUNCTUATION_REGEXP,
} from "./constants.evaluate.js";
import { CJK_REGEXP, PUNCTUATION_REGEXP } from "./constants.evaluate.js";
import { locEnd, locStart } from "./loc.js";

const INLINE_NODE_TYPES = new Set([
Expand Down Expand Up @@ -40,6 +36,8 @@ const KIND_CJ_LETTER = "cj-letter";
const KIND_K_LETTER = "k-letter";
const KIND_CJK_PUNCTUATION = "cjk-punctuation";

const K_REGEXP = /\p{Script_Extensions=Hangul}/u;

/**
* @typedef {" " | "\n" | ""} WhitespaceValue
* @typedef { KIND_NON_CJK | KIND_CJ_LETTER | KIND_K_LETTER | KIND_CJK_PUNCTUATION } WordKind
Expand Down

0 comments on commit ccde7ca

Please sign in to comment.