micromark-extension-cjk-friendly-util 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +28 -0
- package/README.md +139 -0
- package/dist/categoryUtil.d.ts +45 -0
- package/dist/characterWithNonBmp.d.ts +55 -0
- package/dist/classifyCharacter.d.ts +26 -0
- package/dist/codeUtil.d.ts +45 -0
- package/dist/index.cjs +169 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +123 -0
- package/package.json +57 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
Copyright (c) 2025 Tatsunori Uchino <tats.u@live.jp>
|
|
2
|
+
|
|
3
|
+
MIT LICENSE
|
|
4
|
+
|
|
5
|
+
Based on micromark's sub-packages (micromark-util-character, micromark-util-symbol, and micromark-util-classify-character)
|
|
6
|
+
|
|
7
|
+
(The MIT License)
|
|
8
|
+
|
|
9
|
+
Copyright (c) Titus Wormer <tituswormer@gmail.com>
|
|
10
|
+
|
|
11
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
12
|
+
a copy of this software and associated documentation files (the
|
|
13
|
+
'Software'), to deal in the Software without restriction, including
|
|
14
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
15
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
16
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
17
|
+
the following conditions:
|
|
18
|
+
|
|
19
|
+
The above copyright notice and this permission notice shall be
|
|
20
|
+
included in all copies or substantial portions of the Software.
|
|
21
|
+
|
|
22
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
23
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
24
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
25
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
26
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
27
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
28
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# micromark-extension-cjk-friendly-util
|
|
2
|
+
|
|
3
|
+
[](https://npmjs.com/package/micromark-extension-cjk-friendly-util) [](https://npmjs.com/package/micromark-extension-cjk-friendly-util) [](https://npmjs.com/package/micromark-extension-cjk-friendly-util)
|
|
4
|
+
|
|
5
|
+
An utility library package for [micromark-extension-cjk-friendly](https://npmjs.com/package/micromark-extension-cjk-friendly), which is internally used by [remark-cjk-friendly](https://npmjs.com/package/remark-cjk-friendly), and its related packages.
|
|
6
|
+
|
|
7
|
+
## Problem / <span lang="ja">問題</span> / <span lang="zh-Hans-CN">问题</span> / <span lang="ko">문제점</span>
|
|
8
|
+
|
|
9
|
+
CommonMark has a problem that the following emphasis marks `**` are not recognized as emphasis marks in Japanese, Chinese, and Korean.
|
|
10
|
+
|
|
11
|
+
<span lang="ja">CommonMarkには、日本語・中国語・韓国語内の次のような強調記号(`**`)が強調記号として認識されない問題があります。</span>
|
|
12
|
+
|
|
13
|
+
<span lang="zh-Hans-CN">CommonMark存在以下问题:在中文、日语和韩语文本中,强调标记`**`不会被识别为强调标记。</span>
|
|
14
|
+
|
|
15
|
+
<span lang="ko">CommonMark는 일본어와 중국어에서 다음과 같은 강조 표시 `**`가 강조 표시로 인식되지 않는 문제가 있습니다.</span>
|
|
16
|
+
|
|
17
|
+
```md
|
|
18
|
+
**このアスタリスクは強調記号として認識されず、そのまま表示されます。**この文のせいで。
|
|
19
|
+
|
|
20
|
+
**该星号不会被识别,而是直接显示。**这是因为它没有被识别为强调符号。
|
|
21
|
+
|
|
22
|
+
**이 별표는 강조 표시로 인식되지 않고 그대로 표시됩니다(이 괄호 때문에)**이 문장 때문에.
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
This problem occurs because the character just inside the `**` is a (Japanese or Chinese) punctuation mark (。) or parenthesis and the character just outside is not a space or punctuation mark.
|
|
26
|
+
|
|
27
|
+
<span lang="ja">これが起こった原因は、終了側の`**`のすぐ内側が約物(。やカッコ)、かつ外側が約物や空白以外の文字であるためです。</span>
|
|
28
|
+
|
|
29
|
+
<span lang="zh-Hans-CN">这个问题是因为在`**`的结束部分,内侧字符是标点符号(。)或括号,而外侧字符不是空格或标点符号。</span>
|
|
30
|
+
|
|
31
|
+
<span lang="ko">이 문제는 `**` 바로 안쪽의 문자가 (일본어나 중국어) 문장 부호(。) 또는 괄호이고 바깥쪽 문자가 공백이나 문장 부호가 아니기 때문에 발생합니다.</span>
|
|
32
|
+
|
|
33
|
+
Of course, not only the end side but also the start side has the same issue.
|
|
34
|
+
|
|
35
|
+
<span lang="ja">もちろん終了側だけでなく、開始側も同様の問題が存在します。</span>
|
|
36
|
+
|
|
37
|
+
<span lang="zh-Hans-CN">当然,不仅是结束侧,开始侧也存在同样的问题。</span>
|
|
38
|
+
|
|
39
|
+
<span lang="ko">물론 끝나는 부분뿐만 아니라 시작하는 부분에서도 동일한 문제가 있습니다.</span>
|
|
40
|
+
|
|
41
|
+
CommonMark issue: https://github.com/commonmark/commonmark-spec/issues/650
|
|
42
|
+
|
|
43
|
+
## Runtime Requirements / <span lang="ja">実行環境の要件</span> / <span lang="zh-Hans-CN">运行环境要求</span> / <span lang="ko">업데이트 전략</span>
|
|
44
|
+
|
|
45
|
+
This package uses the [`v` flag of the regular expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/unicodeSets) introduced in ES2024 to determine whether the character is an emoji or not.
|
|
46
|
+
|
|
47
|
+
<span lang="ja">本パッケージは文字が絵文字かどうかを判定するために、ES2024で導入された[正規表現の`v`フラグ](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/RegExp/unicodeSets)を使用しています。</span>
|
|
48
|
+
|
|
49
|
+
<span lang="zh-CN">本包使用 ES2024 引入的[`v` 标志](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/unicodeSets) 来判断字符是否为 emoji。</span>
|
|
50
|
+
|
|
51
|
+
<span lang="ko">이 패키지는 ES2024에서 도입된 [`v` 플래그](https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/RegExp/unicodeSets)를 사용하여 문자가 이모지인지 여부를 판단합니다.</span>
|
|
52
|
+
|
|
53
|
+
It makes this package compatible only with relatively recent browsers and Node.js:
|
|
54
|
+
|
|
55
|
+
<span lang="ja">このため、本パッケージは、次のような比較的新しいブラウザやNode.jsでしか動作しません。</span>
|
|
56
|
+
|
|
57
|
+
<span lang="zh-CN">因此,本包只兼容比较新的浏览器和 Node.js:</span>
|
|
58
|
+
|
|
59
|
+
<span lang="ko">따라서, 이 패키지는 비교적 최신 브라우저와 Node.js에서만 작동합니다.</span>
|
|
60
|
+
|
|
61
|
+
- Chrome / Edge 112 or later
|
|
62
|
+
- Firefox 116 or later
|
|
63
|
+
- Safari 17 or later
|
|
64
|
+
- Node.js 20 or later
|
|
65
|
+
|
|
66
|
+
## Installation / <span lang="ja">インストール</span> / <span lang="zh-Hans-CN">安装</span> / <span lang="ko">설치</span>
|
|
67
|
+
|
|
68
|
+
Install `micromark-extension-cjk-friendly-util` via [npm](https://www.npmjs.com/):
|
|
69
|
+
|
|
70
|
+
<span lang="ja">`micromark-extension-cjk-friendly-util`を[npm](https://www.npmjs.com/)でインストールしてください。</span>
|
|
71
|
+
|
|
72
|
+
<span lang="zh-Hans-CN">通过 [npm](https://www.npmjs.com/) 安装 `micromark-extension-cjk-friendly-util`。</span>
|
|
73
|
+
|
|
74
|
+
<span lang="ko">`micromark-extension-cjk-friendly-util`를 [npm](https://www.npmjs.com/)으로 설치하세요.</span>
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
npm install micromark-extension-cjk-friendly-util
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
If you use another package manager, please replace `npm install` with the command of the package manager you use (e.g. `pnpm add` or `yarn add`).
|
|
81
|
+
|
|
82
|
+
<span lang="ja">npm以外のパッケージマネージャを使う場合は、`npm install`を当該パッケージマネージャのコマンド(例:`pnpm add`・`yarn add`)に置き換えてください。</span>
|
|
83
|
+
|
|
84
|
+
<span lang="zh-Hans-CN">如果使用其他包管理器,请将 `npm install` 替换为当时包管理器的命令(例如:`pnpm add`、`yarn add`)。</span>
|
|
85
|
+
|
|
86
|
+
<span lang="ko">다른 패키지 매니저를 사용하는 경우 `npm install`을 해당 패키지 매니저의 명령어(예: `pnpm add`, `yarn add`)로 바꾸어 주세요.</span>
|
|
87
|
+
|
|
88
|
+
## Usage / <span lang="ja">使い方</span> / <span lang="zh-Hans-CN">用法</span> / <span lang="ko">사용법</span>
|
|
89
|
+
|
|
90
|
+
> [!IMPORTANT]
|
|
91
|
+
> Most people do not have to use this package directly. Did you mean:
|
|
92
|
+
>
|
|
93
|
+
> - [remark-cjk-friendly](https://npmjs.com/package/remark-cjk-friendly)
|
|
94
|
+
> - [micromark-extension-cjk-friendly](https://npmjs.com/package/micromark-extension-cjk-friendly)
|
|
95
|
+
|
|
96
|
+
This package provides a function and a namespace based on the original micromark-related packages:
|
|
97
|
+
|
|
98
|
+
| Name | Type | Derived from | Original Name | Description |
|
|
99
|
+
| --- | --- | --- | --- | --- |
|
|
100
|
+
| `classifyCharacter` | function | [micromark-util-character](https://npmjs.com/package/micromark-util-character) | (same) | Tells whether a character is not only a punctuation or whitespace but also a CJK or variation selector |
|
|
101
|
+
| `constantsEx` | namespace | [micromark-util-symbol](https://npmjs.com/package/micromark-util-symbol) | `constants` | Constants meaning CJK and variation selectors; use it and the original `constants` together. |
|
|
102
|
+
|
|
103
|
+
Also, this package provides some utility functions to check whether a character belongs to the category defined in the specification (e.g. CJK code point without variation selector), or to help you fetch the Unicode Code Point of a character around the emphasis mark.
|
|
104
|
+
|
|
105
|
+
## Specification / <span lang="ja">規格書</span> / <span lang="zh-Hans-CN">规范</span> / <span lang="ko">규정서</span>
|
|
106
|
+
|
|
107
|
+
https://github.com/tats-u/markdown-cjk-friendly/blob/main/specification.md (English)
|
|
108
|
+
|
|
109
|
+
## Related packages / <span lang="ja">関連パッケージ</span> / <span lang="zh-Hans-CN">相关包</span> / <span lang="ko">관련 패키지</span>
|
|
110
|
+
|
|
111
|
+
- [micromark-extension-cjk-friendly](https://npmjs.com/package/micromark-extension-cjk-friendly) [](https://npmjs.com/package/micromark-extension-cjk-friendly) [](https://npmjs.com/package/micromark-extension-cjk-friendly) [](https://npmjs.com/package/micromark-extension-cjk-friendly)
|
|
112
|
+
- [remark-cjk-friendly](https://npmjs.com/package/remark-cjk-friendly) [](https://npmjs.com/package/remark-cjk-friendly) [](https://npmjs.com/package/remark-cjk-friendly) [](https://npmjs.com/package/remark-cjk-friendly)
|
|
113
|
+
- [markdown-it-cjk-friendly](https://npmjs.com/package/markdown-it-cjk-friendly) [](https://npmjs.com/package/markdown-it-cjk-friendly) [](https://npmjs.com/package/markdown-it-cjk-friendly) [](https://npmjs.com/package/markdown-it-cjk-friendly)
|
|
114
|
+
- [remark-cjk-friendly](https://npmjs.com/package/remark-cjk-friendly) [](https://npmjs.com/package/remark-cjk-friendly) [](https://npmjs.com/package/remark-cjk-friendly) [](https://npmjs.com/package/remark-cjk-friendly)
|
|
115
|
+
- [micromark-extension-cjk-friendly-gfm-strikethrough](https://npmjs.com/package/micromark-extension-cjk-friendly-gfm-strikethrough) [](https://npmjs.com/package/micromark-extension-cjk-friendly-gfm-strikethrough) [](https://npmjs.com/package/micromark-extension-cjk-friendly-gfm-strikethrough) [](https://npmjs.com/package/micromark-extension-cjk-friendly-gfm-strikethrough)
|
|
116
|
+
|
|
117
|
+
## Contributing / <span lang="ja">貢献</span> / <span lang="zh-Hans-CN">贡献</span> / <span lang="ko">기여</span>
|
|
118
|
+
|
|
119
|
+
### Setup
|
|
120
|
+
|
|
121
|
+
Install the dependencies:
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
pnpm install
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Get Started
|
|
128
|
+
|
|
129
|
+
Build the library:
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
pnpm build
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Build the library in watch mode:
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
pnpm dev
|
|
139
|
+
```
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type classifyCharacter } from "./classifyCharacter.js";
|
|
2
|
+
type Category = ReturnType<typeof classifyCharacter>;
|
|
3
|
+
/**
|
|
4
|
+
* `true` if the code point represents an [Unicode whitespace character](https://spec.commonmark.org/0.31.2/#unicode-whitespace-character).
|
|
5
|
+
*
|
|
6
|
+
* @param category the return value of `classifyCharacter`.
|
|
7
|
+
* @returns `true` if the code point represents an Unicode whitespace character
|
|
8
|
+
*/
|
|
9
|
+
export declare function isUnicodeWhitespace(category: Category): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* `true` if the code point represents a [non-CJK punctuation character](https://github.com/tats-u/markdown-cjk-friendly/blob/main/specification.md#non-cjk-punctuation-character).
|
|
12
|
+
*
|
|
13
|
+
* @param category the return value of `classifyCharacter`.
|
|
14
|
+
* @returns `true` if the code point represents a non-CJK punctuation character
|
|
15
|
+
*/
|
|
16
|
+
export declare function isNonCjkPunctuation(category: Category): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* `true` if the code point represents a [CJK character (CJK code point without variation selector)](https://github.com/tats-u/markdown-cjk-friendly/blob/main/specification.md#cjk-code-point-without-variation-selector).
|
|
19
|
+
*
|
|
20
|
+
* @param category the return value of `classifyCharacter`.
|
|
21
|
+
* @returns `true` if the code point represents a CJK character
|
|
22
|
+
*/
|
|
23
|
+
export declare function isCjk(category: Category): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* `true` if the code point represents an [IVS (Ideographic Variation Selector)](https://github.com/tats-u/markdown-cjk-friendly/blob/main/specification.md#ivs).
|
|
26
|
+
*
|
|
27
|
+
* @param category the return value of `classifyCharacter`.
|
|
28
|
+
* @returns `true` if the code point represents an IVS
|
|
29
|
+
*/
|
|
30
|
+
export declare function isIvs(category: Category): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* `true` if the code point represents a [SVS (Standard Variation Selector/Sequence) that can follow CJK](https://github.com/tats-u/markdown-cjk-friendly/blob/main/specification.md#svs-that-can-follow-cjk).
|
|
33
|
+
*
|
|
34
|
+
* @param category the return value of `classifyCharacter`.
|
|
35
|
+
* @returns `true` if the code point represents an SVS that can follow CJK
|
|
36
|
+
*/
|
|
37
|
+
export declare function isSvsFollowingCjk(category: Category): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* `true` if the code point represents an [Unicode whitespace character](https://spec.commonmark.org/0.31.2/#unicode-whitespace-character) or an [Unicode punctuation character](https://spec.commonmark.org/0.31.2/#unicode-punctuation-character).
|
|
40
|
+
*
|
|
41
|
+
* @param category the return value of `classifyCharacter`.
|
|
42
|
+
* @returns `true` if the code point represents a space or punctuation
|
|
43
|
+
*/
|
|
44
|
+
export declare function isSpaceOrPunctuation(category: Category): boolean;
|
|
45
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { Code } from "micromark-util-types";
|
|
2
|
+
/**
|
|
3
|
+
* Check if `uc` is CJK or IVS
|
|
4
|
+
*
|
|
5
|
+
* @param uc code point
|
|
6
|
+
* @returns `true` if `uc` is CJK, `null` if IVS, or `false` if neither
|
|
7
|
+
*/
|
|
8
|
+
export declare function cjkOrIvs(uc: Code): boolean | null;
|
|
9
|
+
/**
|
|
10
|
+
* Check whether the character code represents Standard Variation Sequence that can follow an ideographic character.
|
|
11
|
+
*
|
|
12
|
+
* U+FE0E is used for some CJK symbols (e.g. U+3299) that can also be
|
|
13
|
+
*/
|
|
14
|
+
export declare const svsFollowingCjk: (code: Code) => boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Check whether the character code represents Unicode punctuation.
|
|
17
|
+
*
|
|
18
|
+
* A **Unicode punctuation** is a character in the Unicode `Pc` (Punctuation,
|
|
19
|
+
* Connector), `Pd` (Punctuation, Dash), `Pe` (Punctuation, Close), `Pf`
|
|
20
|
+
* (Punctuation, Final quote), `Pi` (Punctuation, Initial quote), `Po`
|
|
21
|
+
* (Punctuation, Other), or `Ps` (Punctuation, Open) categories, or an ASCII
|
|
22
|
+
* punctuation (see `asciiPunctuation`).
|
|
23
|
+
*
|
|
24
|
+
* See:
|
|
25
|
+
* **\[UNICODE]**:
|
|
26
|
+
* [The Unicode Standard](https://www.unicode.org/versions/).
|
|
27
|
+
* Unicode Consortium.
|
|
28
|
+
*
|
|
29
|
+
* @param code
|
|
30
|
+
* Code.
|
|
31
|
+
* @returns
|
|
32
|
+
* Whether it matches.
|
|
33
|
+
*/
|
|
34
|
+
export declare const unicodePunctuation: (code: Code) => boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Check whether the character code represents Unicode whitespace.
|
|
37
|
+
*
|
|
38
|
+
* Note that this does handle micromark specific markdown whitespace characters.
|
|
39
|
+
* See `markdownLineEndingOrSpace` to check that.
|
|
40
|
+
*
|
|
41
|
+
* A **Unicode whitespace** is a character in the Unicode `Zs` (Separator,
|
|
42
|
+
* Space) category, or U+0009 CHARACTER TABULATION (HT), U+000A LINE FEED (LF),
|
|
43
|
+
* U+000C (FF), or U+000D CARRIAGE RETURN (CR) (**\[UNICODE]**).
|
|
44
|
+
*
|
|
45
|
+
* See:
|
|
46
|
+
* **\[UNICODE]**:
|
|
47
|
+
* [The Unicode Standard](https://www.unicode.org/versions/).
|
|
48
|
+
* Unicode Consortium.
|
|
49
|
+
*
|
|
50
|
+
* @param code
|
|
51
|
+
* Code.
|
|
52
|
+
* @returns
|
|
53
|
+
* Whether it matches.
|
|
54
|
+
*/
|
|
55
|
+
export declare const unicodeWhitespace: (code: Code) => boolean;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { constants } from "micromark-util-symbol";
|
|
2
|
+
import type { Code } from "micromark-util-types";
|
|
3
|
+
export declare namespace constantsEx {
|
|
4
|
+
const spaceOrPunctuation: 3;
|
|
5
|
+
const cjk: 4096;
|
|
6
|
+
const cjkPunctuation: 4098;
|
|
7
|
+
const ivs: 8192;
|
|
8
|
+
const cjkOrIvs: 12288;
|
|
9
|
+
const svsFollowingCjk: 16384;
|
|
10
|
+
const variationSelector: 28672;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Classify whether a code represents whitespace, punctuation, or something
|
|
14
|
+
* else.
|
|
15
|
+
*
|
|
16
|
+
* Used for attention (emphasis, strong), whose sequences can open or close
|
|
17
|
+
* based on the class of surrounding characters.
|
|
18
|
+
*
|
|
19
|
+
* > 👉 **Note**: eof (`null`) is seen as whitespace.
|
|
20
|
+
*
|
|
21
|
+
* @param code
|
|
22
|
+
* Code.
|
|
23
|
+
* @returns
|
|
24
|
+
* Group.
|
|
25
|
+
*/
|
|
26
|
+
export declare function classifyCharacter(code: Code): typeof constants.characterGroupWhitespace | typeof constants.characterGroupPunctuation | typeof constantsEx.cjk | typeof constantsEx.cjkPunctuation | typeof constantsEx.ivs | typeof constantsEx.svsFollowingCjk | 0;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { Code, Point, TokenizeContext } from "micromark-util-types";
|
|
2
|
+
/**
|
|
3
|
+
* Check if the given code is a [High-Surrogate Code Unit](https://www.unicode.org/glossary/#high_surrogate_code_unit).
|
|
4
|
+
*
|
|
5
|
+
* A High-Surrogate Code Unit is the _first_ half of a [Surrogate Pair](https://www.unicode.org/glossary/#surrogate_pair).
|
|
6
|
+
*
|
|
7
|
+
* @param code Code.
|
|
8
|
+
* @returns `true` if the code is a High-Surrogate Code Unit, `false` otherwise.
|
|
9
|
+
*/
|
|
10
|
+
export declare function isCodeHighSurrogate(code: Code): code is Exclude<Code, null>;
|
|
11
|
+
/**
|
|
12
|
+
* Check if the given code is a [Low-Surrogate Code Unit](https://www.unicode.org/glossary/#low_surrogate_code_unit).
|
|
13
|
+
*
|
|
14
|
+
* A Low-Surrogate Code Unit is the _second_ half of a [Surrogate Pair](https://www.unicode.org/glossary/#surrogate_pair).
|
|
15
|
+
* @param code
|
|
16
|
+
* The character code to check.
|
|
17
|
+
* @returns
|
|
18
|
+
* True if the code is a Low-Surrogate Code Unit, false otherwise.
|
|
19
|
+
*/
|
|
20
|
+
export declare function isCodeLowSurrogate(code: Code): code is Exclude<Code, null>;
|
|
21
|
+
/**
|
|
22
|
+
* If `code` is a [Low-Surrogate Code Unit](https://www.unicode.org/glossary/#low_surrogate_code_unit), try to get a genuine previous [Unicode Scalar Value](https://www.unicode.org/glossary/#unicode_scalar_value) corresponding to the Low-Surrogate Code Unit.
|
|
23
|
+
* @param code a tentative previous [code unit](https://www.unicode.org/glossary/#code_unit) less than 65,536, including a Low-Surrogate one
|
|
24
|
+
* @param nowPoint `this.now()` (`this` = `TokenizeContext`)
|
|
25
|
+
* @param sliceSerialize `this.sliceSerialize` (`this` = `TokenizeContext`)
|
|
26
|
+
* @returns a value greater than 65,535 if the previous code point represents a [Supplementary Character](https://www.unicode.org/glossary/#supplementary_character), or `code` otherwise
|
|
27
|
+
*/
|
|
28
|
+
export declare function tryGetGenuinePreviousCode(code: Exclude<Code, null>, nowPoint: Point, sliceSerialize: TokenizeContext["sliceSerialize"]): Exclude<Code, null>;
|
|
29
|
+
/**
|
|
30
|
+
* Try to get the [Unicode Code Point](https://www.unicode.org/glossary/#code_point) two positions before the current position.
|
|
31
|
+
*
|
|
32
|
+
* @param previousCode a previous code point. Should be greater than 65,535 if it represents a [Supplementary Character](https://www.unicode.org/glossary/#supplementary_character).
|
|
33
|
+
* @param nowPoint `this.now()` (`this` = `TokenizeContext`)
|
|
34
|
+
* @param sliceSerialize `this.sliceSerialize` (`this` = `TokenizeContext`)
|
|
35
|
+
* @returns a value greater than 65,535 if the code point two positions before represents a [Supplementary Character](https://www.unicode.org/glossary/#supplementary_character), a value less than 65,536 for a [BMP Character](https://www.unicode.org/glossary/#bmp_character), or `null` if not found
|
|
36
|
+
*/
|
|
37
|
+
export declare function tryGetCodeTwoBefore(previousCode: Exclude<Code, null>, nowPoint: Point, sliceSerialize: TokenizeContext["sliceSerialize"]): Code;
|
|
38
|
+
/**
|
|
39
|
+
* If `code` is a [High-Surrogate Code Unit](https://www.unicode.org/glossary/#high_surrogate_code_unit), try to get a genuine next [Unicode Scalar Value](https://www.unicode.org/glossary/#unicode_scalar_value) corresponding to the High-Surrogate Code Unit.
|
|
40
|
+
* @param code a tentative next [code unit](https://www.unicode.org/glossary/#code_unit) less than 65,536, including a High-Surrogate one
|
|
41
|
+
* @param nowPoint `this.now()` (`this` = `TokenizeContext`)
|
|
42
|
+
* @param sliceSerialize `this.sliceSerialize` (`this` = `TokenizeContext`)
|
|
43
|
+
* @returns a value greater than 65,535 if the next code point represents a [Supplementary Character](https://www.unicode.org/glossary/#supplementary_character), or `code` otherwise
|
|
44
|
+
*/
|
|
45
|
+
export declare function tryGetGenuineNextCode(code: Exclude<Code, null>, nowPoint: Point, sliceSerialize: TokenizeContext["sliceSerialize"]): Exclude<Code, null>;
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = function(exports1, definition) {
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = function(obj, prop) {
|
|
13
|
+
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
14
|
+
};
|
|
15
|
+
})();
|
|
16
|
+
(()=>{
|
|
17
|
+
__webpack_require__.r = function(exports1) {
|
|
18
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
19
|
+
value: 'Module'
|
|
20
|
+
});
|
|
21
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
22
|
+
value: true
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
})();
|
|
26
|
+
var __webpack_exports__ = {};
|
|
27
|
+
__webpack_require__.r(__webpack_exports__);
|
|
28
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
29
|
+
constantsEx: ()=>classifyCharacter_constantsEx,
|
|
30
|
+
isCjk: ()=>isCjk,
|
|
31
|
+
isSpaceOrPunctuation: ()=>isSpaceOrPunctuation,
|
|
32
|
+
isNonCjkPunctuation: ()=>isNonCjkPunctuation,
|
|
33
|
+
isSvsFollowingCjk: ()=>isSvsFollowingCjk,
|
|
34
|
+
tryGetGenuinePreviousCode: ()=>tryGetGenuinePreviousCode,
|
|
35
|
+
isUnicodeWhitespace: ()=>isUnicodeWhitespace,
|
|
36
|
+
isCodeHighSurrogate: ()=>isCodeHighSurrogate,
|
|
37
|
+
isIvs: ()=>isIvs,
|
|
38
|
+
tryGetCodeTwoBefore: ()=>tryGetCodeTwoBefore,
|
|
39
|
+
classifyCharacter: ()=>classifyCharacter,
|
|
40
|
+
isCodeLowSurrogate: ()=>isCodeLowSurrogate,
|
|
41
|
+
tryGetGenuineNextCode: ()=>tryGetGenuineNextCode
|
|
42
|
+
});
|
|
43
|
+
const external_micromark_util_symbol_namespaceObject = require("micromark-util-symbol");
|
|
44
|
+
const external_micromark_util_character_namespaceObject = require("micromark-util-character");
|
|
45
|
+
const external_get_east_asian_width_namespaceObject = require("get-east-asian-width");
|
|
46
|
+
function cjkOrIvs(uc) {
|
|
47
|
+
if (!uc || uc < 0) return false;
|
|
48
|
+
const eaw = (0, external_get_east_asian_width_namespaceObject.eastAsianWidthType)(uc);
|
|
49
|
+
switch(eaw){
|
|
50
|
+
case "fullwidth":
|
|
51
|
+
case "halfwidth":
|
|
52
|
+
return true;
|
|
53
|
+
case "wide":
|
|
54
|
+
return !/^\p{RGI_Emoji}/v.test(String.fromCodePoint(uc));
|
|
55
|
+
case "narrow":
|
|
56
|
+
return false;
|
|
57
|
+
case "ambiguous":
|
|
58
|
+
return 0xe0100 <= uc && uc <= 0xe01ef && null;
|
|
59
|
+
case "neutral":
|
|
60
|
+
return /^\p{sc=Hangul}/u.test(String.fromCodePoint(uc));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
const svsFollowingCjk = regexCheck(/[\uFE00-\uFE02\uFE0E]/u);
|
|
64
|
+
const unicodePunctuation = regexCheck(/\p{P}|\p{S}/u);
|
|
65
|
+
const unicodeWhitespace = regexCheck(/\s/);
|
|
66
|
+
function regexCheck(regex) {
|
|
67
|
+
return check;
|
|
68
|
+
function check(code) {
|
|
69
|
+
return null !== code && code > -1 && regex.test(String.fromCodePoint(code));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
(function(constantsEx) {
|
|
73
|
+
constantsEx.spaceOrPunctuation = 3;
|
|
74
|
+
constantsEx.cjk = 0x1000;
|
|
75
|
+
constantsEx.cjkPunctuation = 0x1002;
|
|
76
|
+
constantsEx.ivs = 0x2000;
|
|
77
|
+
constantsEx.cjkOrIvs = 0x3000;
|
|
78
|
+
constantsEx.svsFollowingCjk = 0x4000;
|
|
79
|
+
constantsEx.variationSelector = 0x7000;
|
|
80
|
+
})(classifyCharacter_constantsEx || (classifyCharacter_constantsEx = {}));
|
|
81
|
+
function classifyCharacter(code) {
|
|
82
|
+
if (code === external_micromark_util_symbol_namespaceObject.codes.eof || (0, external_micromark_util_character_namespaceObject.markdownLineEndingOrSpace)(code) || unicodeWhitespace(code)) return external_micromark_util_symbol_namespaceObject.constants.characterGroupWhitespace;
|
|
83
|
+
let value = 0;
|
|
84
|
+
if (code >= 0x1100) {
|
|
85
|
+
if (svsFollowingCjk(code)) return classifyCharacter_constantsEx.svsFollowingCjk;
|
|
86
|
+
switch(cjkOrIvs(code)){
|
|
87
|
+
case null:
|
|
88
|
+
return classifyCharacter_constantsEx.ivs;
|
|
89
|
+
case true:
|
|
90
|
+
value |= classifyCharacter_constantsEx.cjk;
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (unicodePunctuation(code)) value |= external_micromark_util_symbol_namespaceObject.constants.characterGroupPunctuation;
|
|
95
|
+
return value;
|
|
96
|
+
}
|
|
97
|
+
var classifyCharacter_constantsEx;
|
|
98
|
+
function isUnicodeWhitespace(category) {
|
|
99
|
+
return Boolean(category & external_micromark_util_symbol_namespaceObject.constants.characterGroupWhitespace);
|
|
100
|
+
}
|
|
101
|
+
function isNonCjkPunctuation(category) {
|
|
102
|
+
return (category & classifyCharacter_constantsEx.cjkPunctuation) === external_micromark_util_symbol_namespaceObject.constants.characterGroupPunctuation;
|
|
103
|
+
}
|
|
104
|
+
function isCjk(category) {
|
|
105
|
+
return Boolean(category & classifyCharacter_constantsEx.cjk);
|
|
106
|
+
}
|
|
107
|
+
function isIvs(category) {
|
|
108
|
+
return category === classifyCharacter_constantsEx.ivs;
|
|
109
|
+
}
|
|
110
|
+
function isSvsFollowingCjk(category) {
|
|
111
|
+
return category === classifyCharacter_constantsEx.svsFollowingCjk;
|
|
112
|
+
}
|
|
113
|
+
function isSpaceOrPunctuation(category) {
|
|
114
|
+
return Boolean(category & classifyCharacter_constantsEx.spaceOrPunctuation);
|
|
115
|
+
}
|
|
116
|
+
function isCodeHighSurrogate(code) {
|
|
117
|
+
return Boolean(code && code >= 0xd800 && code <= 0xdbff);
|
|
118
|
+
}
|
|
119
|
+
function isCodeLowSurrogate(code) {
|
|
120
|
+
return Boolean(code && code >= 0xdc00 && code <= 0xdfff);
|
|
121
|
+
}
|
|
122
|
+
function tryGetGenuinePreviousCode(code, nowPoint, sliceSerialize) {
|
|
123
|
+
if (nowPoint._bufferIndex < 2) return code;
|
|
124
|
+
const previousBuffer = sliceSerialize({
|
|
125
|
+
start: {
|
|
126
|
+
...nowPoint,
|
|
127
|
+
_bufferIndex: nowPoint._bufferIndex - 2
|
|
128
|
+
},
|
|
129
|
+
end: nowPoint
|
|
130
|
+
});
|
|
131
|
+
const previousCandidate = previousBuffer.codePointAt(0);
|
|
132
|
+
return previousCandidate && previousCandidate >= 65536 ? previousCandidate : code;
|
|
133
|
+
}
|
|
134
|
+
function tryGetCodeTwoBefore(previousCode, nowPoint, sliceSerialize) {
|
|
135
|
+
const previousWidth = previousCode >= 65536 ? 2 : 1;
|
|
136
|
+
if (nowPoint._bufferIndex < 1 + previousWidth) return null;
|
|
137
|
+
const idealStart = nowPoint._bufferIndex - previousWidth - 2;
|
|
138
|
+
const twoPreviousBuffer = sliceSerialize({
|
|
139
|
+
start: {
|
|
140
|
+
...nowPoint,
|
|
141
|
+
_bufferIndex: idealStart >= 0 ? idealStart : 0
|
|
142
|
+
},
|
|
143
|
+
end: {
|
|
144
|
+
...nowPoint,
|
|
145
|
+
_bufferIndex: nowPoint._bufferIndex - previousWidth
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
const twoPreviousLast = twoPreviousBuffer.charCodeAt(twoPreviousBuffer.length - 1);
|
|
149
|
+
if (Number.isNaN(twoPreviousLast)) return null;
|
|
150
|
+
if (twoPreviousBuffer.length < 2 || twoPreviousLast < 0xdc00 || 0xdfff < twoPreviousLast) return twoPreviousLast;
|
|
151
|
+
const twoPreviousCandidate = twoPreviousBuffer.codePointAt(0);
|
|
152
|
+
if (twoPreviousCandidate && twoPreviousCandidate >= 65536) return twoPreviousCandidate;
|
|
153
|
+
return twoPreviousLast;
|
|
154
|
+
}
|
|
155
|
+
function tryGetGenuineNextCode(code, nowPoint, sliceSerialize) {
|
|
156
|
+
const nextCandidate = sliceSerialize({
|
|
157
|
+
start: nowPoint,
|
|
158
|
+
end: {
|
|
159
|
+
...nowPoint,
|
|
160
|
+
_bufferIndex: nowPoint._bufferIndex + 2
|
|
161
|
+
}
|
|
162
|
+
}).codePointAt(0);
|
|
163
|
+
return nextCandidate && nextCandidate >= 65536 ? nextCandidate : code;
|
|
164
|
+
}
|
|
165
|
+
var __webpack_export_target__ = exports;
|
|
166
|
+
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
167
|
+
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
|
|
168
|
+
value: true
|
|
169
|
+
});
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { isCjk, isIvs, isNonCjkPunctuation, isSpaceOrPunctuation, isSvsFollowingCjk, isUnicodeWhitespace, } from "./categoryUtil.js";
|
|
2
|
+
export { classifyCharacter, constantsEx } from "./classifyCharacter.js";
|
|
3
|
+
export { isCodeHighSurrogate, isCodeLowSurrogate, tryGetGenuineNextCode, tryGetGenuinePreviousCode, tryGetCodeTwoBefore, } from "./codeUtil.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE_micromark_util_symbol_0f33a452__ from "micromark-util-symbol";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE_micromark_util_character_bdee8a5c__ from "micromark-util-character";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE_get_east_asian_width_c890dec0__ from "get-east-asian-width";
|
|
4
|
+
function cjkOrIvs(uc) {
|
|
5
|
+
if (!uc || uc < 0) return false;
|
|
6
|
+
const eaw = (0, __WEBPACK_EXTERNAL_MODULE_get_east_asian_width_c890dec0__.eastAsianWidthType)(uc);
|
|
7
|
+
switch(eaw){
|
|
8
|
+
case "fullwidth":
|
|
9
|
+
case "halfwidth":
|
|
10
|
+
return true;
|
|
11
|
+
case "wide":
|
|
12
|
+
return !/^\p{RGI_Emoji}/v.test(String.fromCodePoint(uc));
|
|
13
|
+
case "narrow":
|
|
14
|
+
return false;
|
|
15
|
+
case "ambiguous":
|
|
16
|
+
return 0xe0100 <= uc && uc <= 0xe01ef && null;
|
|
17
|
+
case "neutral":
|
|
18
|
+
return /^\p{sc=Hangul}/u.test(String.fromCodePoint(uc));
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
const svsFollowingCjk = regexCheck(/[\uFE00-\uFE02\uFE0E]/u);
|
|
22
|
+
const unicodePunctuation = regexCheck(/\p{P}|\p{S}/u);
|
|
23
|
+
const unicodeWhitespace = regexCheck(/\s/);
|
|
24
|
+
function regexCheck(regex) {
|
|
25
|
+
return check;
|
|
26
|
+
function check(code) {
|
|
27
|
+
return null !== code && code > -1 && regex.test(String.fromCodePoint(code));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
(function(constantsEx) {
|
|
31
|
+
constantsEx.spaceOrPunctuation = 3;
|
|
32
|
+
constantsEx.cjk = 0x1000;
|
|
33
|
+
constantsEx.cjkPunctuation = 0x1002;
|
|
34
|
+
constantsEx.ivs = 0x2000;
|
|
35
|
+
constantsEx.cjkOrIvs = 0x3000;
|
|
36
|
+
constantsEx.svsFollowingCjk = 0x4000;
|
|
37
|
+
constantsEx.variationSelector = 0x7000;
|
|
38
|
+
})(classifyCharacter_constantsEx || (classifyCharacter_constantsEx = {}));
|
|
39
|
+
function classifyCharacter(code) {
|
|
40
|
+
if (code === __WEBPACK_EXTERNAL_MODULE_micromark_util_symbol_0f33a452__.codes.eof || (0, __WEBPACK_EXTERNAL_MODULE_micromark_util_character_bdee8a5c__.markdownLineEndingOrSpace)(code) || unicodeWhitespace(code)) return __WEBPACK_EXTERNAL_MODULE_micromark_util_symbol_0f33a452__.constants.characterGroupWhitespace;
|
|
41
|
+
let value = 0;
|
|
42
|
+
if (code >= 0x1100) {
|
|
43
|
+
if (svsFollowingCjk(code)) return classifyCharacter_constantsEx.svsFollowingCjk;
|
|
44
|
+
switch(cjkOrIvs(code)){
|
|
45
|
+
case null:
|
|
46
|
+
return classifyCharacter_constantsEx.ivs;
|
|
47
|
+
case true:
|
|
48
|
+
value |= classifyCharacter_constantsEx.cjk;
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (unicodePunctuation(code)) value |= __WEBPACK_EXTERNAL_MODULE_micromark_util_symbol_0f33a452__.constants.characterGroupPunctuation;
|
|
53
|
+
return value;
|
|
54
|
+
}
|
|
55
|
+
var classifyCharacter_constantsEx;
|
|
56
|
+
function isUnicodeWhitespace(category) {
|
|
57
|
+
return Boolean(category & __WEBPACK_EXTERNAL_MODULE_micromark_util_symbol_0f33a452__.constants.characterGroupWhitespace);
|
|
58
|
+
}
|
|
59
|
+
function isNonCjkPunctuation(category) {
|
|
60
|
+
return (category & classifyCharacter_constantsEx.cjkPunctuation) === __WEBPACK_EXTERNAL_MODULE_micromark_util_symbol_0f33a452__.constants.characterGroupPunctuation;
|
|
61
|
+
}
|
|
62
|
+
function isCjk(category) {
|
|
63
|
+
return Boolean(category & classifyCharacter_constantsEx.cjk);
|
|
64
|
+
}
|
|
65
|
+
function isIvs(category) {
|
|
66
|
+
return category === classifyCharacter_constantsEx.ivs;
|
|
67
|
+
}
|
|
68
|
+
function isSvsFollowingCjk(category) {
|
|
69
|
+
return category === classifyCharacter_constantsEx.svsFollowingCjk;
|
|
70
|
+
}
|
|
71
|
+
function isSpaceOrPunctuation(category) {
|
|
72
|
+
return Boolean(category & classifyCharacter_constantsEx.spaceOrPunctuation);
|
|
73
|
+
}
|
|
74
|
+
function isCodeHighSurrogate(code) {
|
|
75
|
+
return Boolean(code && code >= 0xd800 && code <= 0xdbff);
|
|
76
|
+
}
|
|
77
|
+
function isCodeLowSurrogate(code) {
|
|
78
|
+
return Boolean(code && code >= 0xdc00 && code <= 0xdfff);
|
|
79
|
+
}
|
|
80
|
+
function tryGetGenuinePreviousCode(code, nowPoint, sliceSerialize) {
|
|
81
|
+
if (nowPoint._bufferIndex < 2) return code;
|
|
82
|
+
const previousBuffer = sliceSerialize({
|
|
83
|
+
start: {
|
|
84
|
+
...nowPoint,
|
|
85
|
+
_bufferIndex: nowPoint._bufferIndex - 2
|
|
86
|
+
},
|
|
87
|
+
end: nowPoint
|
|
88
|
+
});
|
|
89
|
+
const previousCandidate = previousBuffer.codePointAt(0);
|
|
90
|
+
return previousCandidate && previousCandidate >= 65536 ? previousCandidate : code;
|
|
91
|
+
}
|
|
92
|
+
function tryGetCodeTwoBefore(previousCode, nowPoint, sliceSerialize) {
|
|
93
|
+
const previousWidth = previousCode >= 65536 ? 2 : 1;
|
|
94
|
+
if (nowPoint._bufferIndex < 1 + previousWidth) return null;
|
|
95
|
+
const idealStart = nowPoint._bufferIndex - previousWidth - 2;
|
|
96
|
+
const twoPreviousBuffer = sliceSerialize({
|
|
97
|
+
start: {
|
|
98
|
+
...nowPoint,
|
|
99
|
+
_bufferIndex: idealStart >= 0 ? idealStart : 0
|
|
100
|
+
},
|
|
101
|
+
end: {
|
|
102
|
+
...nowPoint,
|
|
103
|
+
_bufferIndex: nowPoint._bufferIndex - previousWidth
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
const twoPreviousLast = twoPreviousBuffer.charCodeAt(twoPreviousBuffer.length - 1);
|
|
107
|
+
if (Number.isNaN(twoPreviousLast)) return null;
|
|
108
|
+
if (twoPreviousBuffer.length < 2 || twoPreviousLast < 0xdc00 || 0xdfff < twoPreviousLast) return twoPreviousLast;
|
|
109
|
+
const twoPreviousCandidate = twoPreviousBuffer.codePointAt(0);
|
|
110
|
+
if (twoPreviousCandidate && twoPreviousCandidate >= 65536) return twoPreviousCandidate;
|
|
111
|
+
return twoPreviousLast;
|
|
112
|
+
}
|
|
113
|
+
function tryGetGenuineNextCode(code, nowPoint, sliceSerialize) {
|
|
114
|
+
const nextCandidate = sliceSerialize({
|
|
115
|
+
start: nowPoint,
|
|
116
|
+
end: {
|
|
117
|
+
...nowPoint,
|
|
118
|
+
_bufferIndex: nowPoint._bufferIndex + 2
|
|
119
|
+
}
|
|
120
|
+
}).codePointAt(0);
|
|
121
|
+
return nextCandidate && nextCandidate >= 65536 ? nextCandidate : code;
|
|
122
|
+
}
|
|
123
|
+
export { classifyCharacter, classifyCharacter_constantsEx as constantsEx, isCjk, isCodeHighSurrogate, isCodeLowSurrogate, isIvs, isNonCjkPunctuation, isSpaceOrPunctuation, isSvsFollowingCjk, isUnicodeWhitespace, tryGetCodeTwoBefore, tryGetGenuineNextCode, tryGetGenuinePreviousCode };
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "micromark-extension-cjk-friendly-util",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"exports": {
|
|
6
|
+
".": {
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"default": "./dist/index.js"
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"LICENSE",
|
|
14
|
+
"README.md"
|
|
15
|
+
],
|
|
16
|
+
"repository": {
|
|
17
|
+
"url": "https://github.com/tats-u/markdown-cjk-friendly"
|
|
18
|
+
},
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"author": "Tatsunori Uchino <tats.u@live.jp> (https://github.com/tats-u)",
|
|
21
|
+
"bugs": "https://github.com/tats-u/markdown-cjk-friendly/issues",
|
|
22
|
+
"keywords": [
|
|
23
|
+
"micromark-extension",
|
|
24
|
+
"micromark",
|
|
25
|
+
"markdown",
|
|
26
|
+
"japanese",
|
|
27
|
+
"chinese",
|
|
28
|
+
"korean",
|
|
29
|
+
"cjk"
|
|
30
|
+
],
|
|
31
|
+
"description": "common library for micromark-extension-cjk-friendly and its related packages",
|
|
32
|
+
"sideEffects": false,
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"get-east-asian-width": "^1.3.0",
|
|
35
|
+
"micromark-util-character": "^2.0.0",
|
|
36
|
+
"micromark-util-symbol": "^2.0.0"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"micromark-util-types": "^2.0.0"
|
|
40
|
+
},
|
|
41
|
+
"peerDependenciesMeta": {
|
|
42
|
+
"micromark-util-types": {
|
|
43
|
+
"optional": true
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"engines": {
|
|
47
|
+
"node": ">=20"
|
|
48
|
+
},
|
|
49
|
+
"scripts": {
|
|
50
|
+
"build": "rslib build",
|
|
51
|
+
"dev": "rslib build --watch",
|
|
52
|
+
"test": "vitest --run",
|
|
53
|
+
"test:up": "vitest -u",
|
|
54
|
+
"test:watch": "vitest watch",
|
|
55
|
+
"lint:type": "tsc --noEmit"
|
|
56
|
+
}
|
|
57
|
+
}
|