micromark-extension-cjk-friendly 0.1.0 → 1.0.1
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 +23 -17
- package/README.md +27 -1
- package/dist/index.js +18 -118
- package/package.json +18 -22
- package/dist/ext/characterWithNonBmp.d.ts +0 -55
- package/dist/ext/classifyCharacter.d.ts +0 -26
- package/dist/index.cjs +0 -346
package/LICENSE
CHANGED
|
@@ -1,22 +1,28 @@
|
|
|
1
|
-
Copyright (c)
|
|
1
|
+
Copyright (c) 2025 Tatsunori Uchino <tats.u@live.jp>
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
MIT LICENSE
|
|
4
|
+
|
|
5
|
+
Based on micromark and micromark-core-commonmark
|
|
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:
|
|
11
18
|
|
|
12
19
|
The above copyright notice and this permission notice shall be
|
|
13
20
|
included in all copies or substantial portions of the Software.
|
|
14
21
|
|
|
15
|
-
THE SOFTWARE IS PROVIDED
|
|
16
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
OTHER DEALINGS IN THE SOFTWARE.
|
|
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# micromark-extension-cjk-friendly
|
|
2
2
|
|
|
3
|
-
[](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)
|
|
4
4
|
|
|
5
5
|
A [micromark](https://github.com/micromark/micromark) extension to make Markdown emphasis (`**`) in CommonMark compatible with Chinese, Japanese, and Korean (CJK).
|
|
6
6
|
|
|
@@ -10,6 +10,15 @@ A [micromark](https://github.com/micromark/micromark) extension to make Markdown
|
|
|
10
10
|
|
|
11
11
|
<span lang="ko">CommonMark의 강조 표시(`**`) 를 한국어, 중국어, 일본어와 호환되도록 만드는 [micromark](https://github.com/micromark/micromark) 확장</span>
|
|
12
12
|
|
|
13
|
+
> [!NOTE]
|
|
14
|
+
> This package does not support the strikethrough syntax (`~~`) in GFM (GitHub Flavored Markdown). If you want to support it, please use [`micromark-extension-cjk-friendly-gfm-strikethrough`](https://npmjs.com/package/micromark-extension-cjk-friendly-gfm-strikethrough) along with this package.
|
|
15
|
+
>
|
|
16
|
+
> <span lang="ja">本パッケージはGitHub Flavored Markdown(GFM)の取り消し線(`~~`)に対応しません。対応させたい場合は、[`micromark-extension-cjk-friendly-gfm-strikethrough`](https://npmjs.com/package/micromark-extension-cjk-friendly-gfm-strikethrough)を併用してください。</span>
|
|
17
|
+
>
|
|
18
|
+
> <span lang="zh-Hans-CN">本包不支持 GitHub Flavored Markdown(GFM)的删除线(`~~`)。如果需要支持,请同时使用 [`micromark-extension-cjk-friendly-gfm-strikethrough`](https://npmjs.com/package/micromark-extension-cjk-friendly-gfm-strikethrough)。</span>
|
|
19
|
+
>
|
|
20
|
+
> <span lang="ko">이 패키지는 GitHub Flavored Markdown(GFM)의 취소선(`~~`)을 지원하지 않습니다. 지원하고 싶은 경우에는 [`micromark-extension-cjk-friendly-gfm-strikethrough`](https://npmjs.com/package/micromark-extension-cjk-friendly-gfm-strikethrough)를 함께 사용해 주세요.</span>
|
|
21
|
+
|
|
13
22
|
## Problem / <span lang="ja">問題</span> / <span lang="zh-Hans-CN">问题</span> / <span lang="ko">문제점</span>
|
|
14
23
|
|
|
15
24
|
CommonMark has a problem that the following emphasis marks `**` are not recognized as emphasis marks in Japanese, Chinese, and Korean.
|
|
@@ -116,10 +125,27 @@ const htmlString = micromark(
|
|
|
116
125
|
)
|
|
117
126
|
```
|
|
118
127
|
|
|
128
|
+
## Compatibility with the other languages / <span lang="ja">他言語との互換性</span> / <span lang="zh-Hans-CN">与其他语言的兼容性</span> / <span lang="ko">다른 언어와의 호환성</span>
|
|
129
|
+
|
|
130
|
+
This modification of the specification does not affect the other languages than Chinese, Japanese, and Korean. Even if your application or document has translations or content in other languages, it will not be affected, so please feel free to use this packages. I assure that even with this package (amendment suggestion), micromark still outputs the same HTML for all CommonMark test cases as of 0.31.2.
|
|
131
|
+
|
|
132
|
+
<span lang="ja">この仕様変更提案は、日本語・中国語・韓国語以外の言語には影響しません。アプリケーションやドキュメントに他言語の翻訳やコンテンツが含まれていても影響はありませんので、安心して本パッケージをご利用ください。</span>
|
|
133
|
+
|
|
134
|
+
<span lang="zh-Hans-CN">除中文、日文和韩文外,建议的规范变更不会影响其他语言。请放心使用此软件包,因为如果您的应用程序或文档包含其他语言的翻译或内容,也不会受到影响。我保证,即使使用此软件包(修正建议),micromark 仍然会为 0.31.2 版本的所有 CommonMark 测试用例输出相同的 HTML。</span>
|
|
135
|
+
|
|
136
|
+
<span lang="ko">이번 사양 변경 제안은 한국어, 중국어, 일본어 이외의 언어에는 영향을 미치지 않습니다. 애플리케이션이나 문서에 다른 언어의 번역이나 콘텐츠가 포함되어 있어도 영향을 받지 않으므로 안심하고 본 패키지를 사용하시기 바랍니다. 본 패키지(수정안)를 사용해도 0.31.2 시점의 모든 CommonMark 테스트케이스에서 micromark가 동일한 HTML을 출력하는 것을 보장합니다.</span>
|
|
137
|
+
|
|
119
138
|
## Specification / <span lang="ja">規格書</span> / <span lang="zh-Hans-CN">规范</span> / <span lang="ko">규정서</span>
|
|
120
139
|
|
|
121
140
|
https://github.com/tats-u/markdown-cjk-friendly/blob/main/specification.md (English)
|
|
122
141
|
|
|
142
|
+
## Related packages / <span lang="ja">関連パッケージ</span> / <span lang="zh-Hans-CN">相关包</span> / <span lang="ko">관련 패키지</span>
|
|
143
|
+
|
|
144
|
+
- [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)
|
|
145
|
+
- [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)
|
|
146
|
+
- [micromark-extension-cjk-friendly-util](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) [](https://npmjs.com/package/micromark-extension-cjk-friendly-util)
|
|
147
|
+
- [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)
|
|
148
|
+
|
|
123
149
|
## Contributing / <span lang="ja">貢献</span> / <span lang="zh-Hans-CN">贡献</span> / <span lang="ko">기여</span>
|
|
124
150
|
|
|
125
151
|
### Setup
|
package/dist/index.js
CHANGED
|
@@ -1,61 +1,8 @@
|
|
|
1
1
|
import * as __WEBPACK_EXTERNAL_MODULE_micromark_util_symbol_0f33a452__ from "micromark-util-symbol";
|
|
2
2
|
import * as __WEBPACK_EXTERNAL_MODULE_devlop__ from "devlop";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE_micromark_extension_cjk_friendly_util_03e06879__ from "micromark-extension-cjk-friendly-util";
|
|
3
4
|
import * as __WEBPACK_EXTERNAL_MODULE_micromark_util_chunked_0c4f2f7c__ from "micromark-util-chunked";
|
|
4
5
|
import * as __WEBPACK_EXTERNAL_MODULE_micromark_util_resolve_all_7bf88077__ from "micromark-util-resolve-all";
|
|
5
|
-
import * as __WEBPACK_EXTERNAL_MODULE_micromark_util_character_bdee8a5c__ from "micromark-util-character";
|
|
6
|
-
import * as __WEBPACK_EXTERNAL_MODULE_get_east_asian_width_c890dec0__ from "get-east-asian-width";
|
|
7
|
-
function cjkOrIvs(uc) {
|
|
8
|
-
if (!uc || uc < 0) return false;
|
|
9
|
-
const eaw = (0, __WEBPACK_EXTERNAL_MODULE_get_east_asian_width_c890dec0__.eastAsianWidthType)(uc);
|
|
10
|
-
switch(eaw){
|
|
11
|
-
case "fullwidth":
|
|
12
|
-
case "halfwidth":
|
|
13
|
-
return true;
|
|
14
|
-
case "wide":
|
|
15
|
-
return !/^\p{RGI_Emoji}/v.test(String.fromCodePoint(uc));
|
|
16
|
-
case "narrow":
|
|
17
|
-
return false;
|
|
18
|
-
case "ambiguous":
|
|
19
|
-
return 0xe0100 <= uc && uc <= 0xe01ef && null;
|
|
20
|
-
case "neutral":
|
|
21
|
-
return /^\p{sc=Hangul}/u.test(String.fromCodePoint(uc));
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
const svsFollowingCjk = regexCheck(/[\uFE00-\uFE02\uFE0E]/u);
|
|
25
|
-
const unicodePunctuation = regexCheck(/\p{P}|\p{S}/u);
|
|
26
|
-
const unicodeWhitespace = regexCheck(/\s/);
|
|
27
|
-
function regexCheck(regex) {
|
|
28
|
-
return check;
|
|
29
|
-
function check(code) {
|
|
30
|
-
return null !== code && code > -1 && regex.test(String.fromCodePoint(code));
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
(function(constantsEx) {
|
|
34
|
-
constantsEx.spaceOrPunctuation = 3;
|
|
35
|
-
constantsEx.cjk = 0x1000;
|
|
36
|
-
constantsEx.cjkPunctuation = 0x1002;
|
|
37
|
-
constantsEx.ivs = 0x2000;
|
|
38
|
-
constantsEx.cjkOrIvs = 0x3000;
|
|
39
|
-
constantsEx.svsFollowingCjk = 0x4000;
|
|
40
|
-
constantsEx.variationSelector = 0x7000;
|
|
41
|
-
})(classifyCharacter_constantsEx || (classifyCharacter_constantsEx = {}));
|
|
42
|
-
function classifyCharacter(code) {
|
|
43
|
-
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;
|
|
44
|
-
let value = 0;
|
|
45
|
-
if (code >= 0x1100) {
|
|
46
|
-
if (svsFollowingCjk(code)) return classifyCharacter_constantsEx.svsFollowingCjk;
|
|
47
|
-
switch(cjkOrIvs(code)){
|
|
48
|
-
case null:
|
|
49
|
-
return classifyCharacter_constantsEx.ivs;
|
|
50
|
-
case true:
|
|
51
|
-
value |= classifyCharacter_constantsEx.cjk;
|
|
52
|
-
break;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
if (unicodePunctuation(code)) value |= __WEBPACK_EXTERNAL_MODULE_micromark_util_symbol_0f33a452__.constants.characterGroupPunctuation;
|
|
56
|
-
return value;
|
|
57
|
-
}
|
|
58
|
-
var classifyCharacter_constantsEx;
|
|
59
6
|
const attention = {
|
|
60
7
|
name: "attention",
|
|
61
8
|
resolveAll: resolveAllAttention,
|
|
@@ -207,49 +154,13 @@ function resolveAllAttention(events, context) {
|
|
|
207
154
|
}
|
|
208
155
|
function tokenizeAttention(effects, ok) {
|
|
209
156
|
const attentionMarkers = this.parser.constructs.attentionMarkers.null;
|
|
210
|
-
|
|
211
|
-
const
|
|
212
|
-
|
|
213
|
-
const nowPoint = now();
|
|
214
|
-
if (nowPoint._bufferIndex >= 2) {
|
|
215
|
-
const previousBuffer = sliceSerialize({
|
|
216
|
-
start: {
|
|
217
|
-
...nowPoint,
|
|
218
|
-
_bufferIndex: nowPoint._bufferIndex - 2
|
|
219
|
-
},
|
|
220
|
-
end: nowPoint
|
|
221
|
-
});
|
|
222
|
-
const previousCandidate = previousBuffer.codePointAt(0);
|
|
223
|
-
if (previousCandidate && previousCandidate >= 65536) previous = previousCandidate;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
const before = classifyCharacter(previous);
|
|
157
|
+
const { now, sliceSerialize, previous: tentativePrevious } = this;
|
|
158
|
+
const previous = (0, __WEBPACK_EXTERNAL_MODULE_micromark_extension_cjk_friendly_util_03e06879__.isCodeLowSurrogate)(tentativePrevious) ? (0, __WEBPACK_EXTERNAL_MODULE_micromark_extension_cjk_friendly_util_03e06879__.tryGetGenuinePreviousCode)(tentativePrevious, now(), sliceSerialize) : tentativePrevious;
|
|
159
|
+
const before = (0, __WEBPACK_EXTERNAL_MODULE_micromark_extension_cjk_friendly_util_03e06879__.classifyCharacter)(previous);
|
|
227
160
|
let beforePrimary = before;
|
|
228
|
-
if (
|
|
229
|
-
const
|
|
230
|
-
|
|
231
|
-
if (nowPoint._bufferIndex >= 1 + previousWidth) {
|
|
232
|
-
const idealStart = nowPoint._bufferIndex - previousWidth - 2;
|
|
233
|
-
const twoPreviousBuffer = sliceSerialize({
|
|
234
|
-
start: {
|
|
235
|
-
...nowPoint,
|
|
236
|
-
_bufferIndex: idealStart >= 0 ? idealStart : 0
|
|
237
|
-
},
|
|
238
|
-
end: {
|
|
239
|
-
...nowPoint,
|
|
240
|
-
_bufferIndex: nowPoint._bufferIndex - previousWidth
|
|
241
|
-
}
|
|
242
|
-
});
|
|
243
|
-
const twoPreviousLast = twoPreviousBuffer.charCodeAt(twoPreviousBuffer.length - 1);
|
|
244
|
-
if (!Number.isNaN(twoPreviousLast)) {
|
|
245
|
-
let twoPrevious;
|
|
246
|
-
if (twoPreviousBuffer.length >= 2 && twoPreviousLast >= 0xdc00 && twoPreviousLast <= 0xdfff) {
|
|
247
|
-
const twoPreviousCandidate = twoPreviousBuffer.codePointAt(0);
|
|
248
|
-
twoPrevious = twoPreviousCandidate && twoPreviousCandidate >= 65536 ? twoPreviousCandidate : twoPreviousLast;
|
|
249
|
-
} else twoPrevious = twoPreviousLast;
|
|
250
|
-
beforePrimary = classifyCharacter(twoPrevious);
|
|
251
|
-
}
|
|
252
|
-
}
|
|
161
|
+
if ((0, __WEBPACK_EXTERNAL_MODULE_micromark_extension_cjk_friendly_util_03e06879__.isSvsFollowingCjk)(before)) {
|
|
162
|
+
const twoPrevious = (0, __WEBPACK_EXTERNAL_MODULE_micromark_extension_cjk_friendly_util_03e06879__.tryGetCodeTwoBefore)(previous, now(), sliceSerialize);
|
|
163
|
+
if (null !== twoPrevious) beforePrimary = (0, __WEBPACK_EXTERNAL_MODULE_micromark_extension_cjk_friendly_util_03e06879__.classifyCharacter)(twoPrevious);
|
|
253
164
|
}
|
|
254
165
|
let marker;
|
|
255
166
|
return start;
|
|
@@ -265,29 +176,18 @@ function tokenizeAttention(effects, ok) {
|
|
|
265
176
|
return inside;
|
|
266
177
|
}
|
|
267
178
|
const token = effects.exit("attentionSequence");
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
const nowPoint = now();
|
|
271
|
-
const nextCandidate = sliceSerialize({
|
|
272
|
-
start: nowPoint,
|
|
273
|
-
end: {
|
|
274
|
-
...nowPoint,
|
|
275
|
-
_bufferIndex: nowPoint._bufferIndex + 2
|
|
276
|
-
}
|
|
277
|
-
}).codePointAt(0);
|
|
278
|
-
if (nextCandidate && nextCandidate >= 65536) next = nextCandidate;
|
|
279
|
-
}
|
|
280
|
-
const after = classifyCharacter(next);
|
|
179
|
+
const next = (0, __WEBPACK_EXTERNAL_MODULE_micromark_extension_cjk_friendly_util_03e06879__.isCodeHighSurrogate)(code) ? (0, __WEBPACK_EXTERNAL_MODULE_micromark_extension_cjk_friendly_util_03e06879__.tryGetGenuineNextCode)(code, now(), sliceSerialize) : code;
|
|
180
|
+
const after = (0, __WEBPACK_EXTERNAL_MODULE_micromark_extension_cjk_friendly_util_03e06879__.classifyCharacter)(next);
|
|
281
181
|
(0, __WEBPACK_EXTERNAL_MODULE_devlop__.ok)(attentionMarkers, "expected `attentionMarkers` to be populated");
|
|
282
|
-
const beforeNonCjkPunctuation =
|
|
283
|
-
const beforeSpaceOrNonCjkPunctuation =
|
|
284
|
-
const afterNonCjkPunctuation =
|
|
285
|
-
const afterSpaceOrNonCjkPunctuation =
|
|
286
|
-
const beforeCjkOrIvs =
|
|
287
|
-
const open =
|
|
288
|
-
const close =
|
|
289
|
-
token._open = Boolean(marker === __WEBPACK_EXTERNAL_MODULE_micromark_util_symbol_0f33a452__.codes.asterisk ? open : open && (
|
|
290
|
-
token._close = Boolean(marker === __WEBPACK_EXTERNAL_MODULE_micromark_util_symbol_0f33a452__.codes.asterisk ? close : close && (
|
|
182
|
+
const beforeNonCjkPunctuation = (0, __WEBPACK_EXTERNAL_MODULE_micromark_extension_cjk_friendly_util_03e06879__.isNonCjkPunctuation)(before);
|
|
183
|
+
const beforeSpaceOrNonCjkPunctuation = beforeNonCjkPunctuation || (0, __WEBPACK_EXTERNAL_MODULE_micromark_extension_cjk_friendly_util_03e06879__.isUnicodeWhitespace)(before);
|
|
184
|
+
const afterNonCjkPunctuation = (0, __WEBPACK_EXTERNAL_MODULE_micromark_extension_cjk_friendly_util_03e06879__.isNonCjkPunctuation)(after);
|
|
185
|
+
const afterSpaceOrNonCjkPunctuation = afterNonCjkPunctuation || (0, __WEBPACK_EXTERNAL_MODULE_micromark_extension_cjk_friendly_util_03e06879__.isUnicodeWhitespace)(after);
|
|
186
|
+
const beforeCjkOrIvs = (0, __WEBPACK_EXTERNAL_MODULE_micromark_extension_cjk_friendly_util_03e06879__.isCjk)(beforePrimary) || (0, __WEBPACK_EXTERNAL_MODULE_micromark_extension_cjk_friendly_util_03e06879__.isIvs)(before);
|
|
187
|
+
const open = !afterSpaceOrNonCjkPunctuation || afterNonCjkPunctuation && (beforeSpaceOrNonCjkPunctuation || beforeCjkOrIvs) || attentionMarkers.includes(code);
|
|
188
|
+
const close = !beforeSpaceOrNonCjkPunctuation || beforeNonCjkPunctuation && (afterSpaceOrNonCjkPunctuation || (0, __WEBPACK_EXTERNAL_MODULE_micromark_extension_cjk_friendly_util_03e06879__.isCjk)(after)) || attentionMarkers.includes(previous);
|
|
189
|
+
token._open = Boolean(marker === __WEBPACK_EXTERNAL_MODULE_micromark_util_symbol_0f33a452__.codes.asterisk ? open : open && ((0, __WEBPACK_EXTERNAL_MODULE_micromark_extension_cjk_friendly_util_03e06879__.isSpaceOrPunctuation)(before) || !close));
|
|
190
|
+
token._close = Boolean(marker === __WEBPACK_EXTERNAL_MODULE_micromark_util_symbol_0f33a452__.codes.asterisk ? close : close && ((0, __WEBPACK_EXTERNAL_MODULE_micromark_extension_cjk_friendly_util_03e06879__.isSpaceOrPunctuation)(after) || !open));
|
|
291
191
|
return ok(code);
|
|
292
192
|
}
|
|
293
193
|
}
|
package/package.json
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "micromark-extension-cjk-friendly",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
|
-
"
|
|
9
|
-
"module-sync": "./dist/index.js",
|
|
10
|
-
"require": "./dist/index.cjs"
|
|
8
|
+
"default": "./dist/index.js"
|
|
11
9
|
}
|
|
12
10
|
},
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"LICENSE",
|
|
14
|
+
"README.md"
|
|
15
|
+
],
|
|
17
16
|
"repository": {
|
|
18
17
|
"url": "https://github.com/tats-u/markdown-cjk-friendly"
|
|
19
18
|
},
|
|
@@ -31,25 +30,14 @@
|
|
|
31
30
|
],
|
|
32
31
|
"description": "micromark extension to make Markdown emphasis (`**`) in CommonMark more friendly with Chinese, Japanese, and Korean (CJK)",
|
|
33
32
|
"sideEffects": false,
|
|
34
|
-
"scripts": {
|
|
35
|
-
"build": "rslib build",
|
|
36
|
-
"dev": "rslib build --watch",
|
|
37
|
-
"test": "vitest --run",
|
|
38
|
-
"test:up": "vitest -u",
|
|
39
|
-
"test:watch": "vitest watch",
|
|
40
|
-
"lint:type": "tsc --noEmit",
|
|
41
|
-
"prepack": "node -e \"require('fs').cpSync('../../LICENSE', './LICENSE')\""
|
|
42
|
-
},
|
|
43
33
|
"dependencies": {
|
|
44
34
|
"devlop": "^1.0.0",
|
|
45
|
-
"get-east-asian-width": "^1.3.0",
|
|
46
|
-
"micromark-util-character": "^2.0.0",
|
|
47
35
|
"micromark-util-chunked": "^2.0.0",
|
|
48
36
|
"micromark-util-resolve-all": "^2.0.0",
|
|
49
|
-
"micromark-util-symbol": "^2.0.0"
|
|
37
|
+
"micromark-util-symbol": "^2.0.0",
|
|
38
|
+
"micromark-extension-cjk-friendly-util": "^1.0.0"
|
|
50
39
|
},
|
|
51
40
|
"devDependencies": {
|
|
52
|
-
"@rslib/core": "^0.3.1",
|
|
53
41
|
"micromark": "^4.0.1",
|
|
54
42
|
"micromark-extension-gfm": "^3.0.0",
|
|
55
43
|
"micromark-util-types": "^2.0.0"
|
|
@@ -65,5 +53,13 @@
|
|
|
65
53
|
},
|
|
66
54
|
"engines": {
|
|
67
55
|
"node": ">=20"
|
|
56
|
+
},
|
|
57
|
+
"scripts": {
|
|
58
|
+
"build": "rslib build",
|
|
59
|
+
"dev": "rslib build --watch",
|
|
60
|
+
"test": "vitest --run",
|
|
61
|
+
"test:up": "vitest -u",
|
|
62
|
+
"test:watch": "vitest watch",
|
|
63
|
+
"lint:type": "tsc --noEmit"
|
|
68
64
|
}
|
|
69
|
-
}
|
|
65
|
+
}
|
|
@@ -1,55 +0,0 @@
|
|
|
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;
|
|
@@ -1,26 +0,0 @@
|
|
|
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;
|
package/dist/index.cjs
DELETED
|
@@ -1,346 +0,0 @@
|
|
|
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
|
-
cjkFriendlyExtension: ()=>cjkFriendlyExtension
|
|
30
|
-
});
|
|
31
|
-
const external_micromark_util_symbol_namespaceObject = require("micromark-util-symbol");
|
|
32
|
-
const external_devlop_namespaceObject = require("devlop");
|
|
33
|
-
const external_micromark_util_chunked_namespaceObject = require("micromark-util-chunked");
|
|
34
|
-
const external_micromark_util_resolve_all_namespaceObject = require("micromark-util-resolve-all");
|
|
35
|
-
const external_micromark_util_character_namespaceObject = require("micromark-util-character");
|
|
36
|
-
const external_get_east_asian_width_namespaceObject = require("get-east-asian-width");
|
|
37
|
-
function cjkOrIvs(uc) {
|
|
38
|
-
if (!uc || uc < 0) return false;
|
|
39
|
-
const eaw = (0, external_get_east_asian_width_namespaceObject.eastAsianWidthType)(uc);
|
|
40
|
-
switch(eaw){
|
|
41
|
-
case "fullwidth":
|
|
42
|
-
case "halfwidth":
|
|
43
|
-
return true;
|
|
44
|
-
case "wide":
|
|
45
|
-
return !/^\p{RGI_Emoji}/v.test(String.fromCodePoint(uc));
|
|
46
|
-
case "narrow":
|
|
47
|
-
return false;
|
|
48
|
-
case "ambiguous":
|
|
49
|
-
return 0xe0100 <= uc && uc <= 0xe01ef && null;
|
|
50
|
-
case "neutral":
|
|
51
|
-
return /^\p{sc=Hangul}/u.test(String.fromCodePoint(uc));
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
const svsFollowingCjk = regexCheck(/[\uFE00-\uFE02\uFE0E]/u);
|
|
55
|
-
const unicodePunctuation = regexCheck(/\p{P}|\p{S}/u);
|
|
56
|
-
const unicodeWhitespace = regexCheck(/\s/);
|
|
57
|
-
function regexCheck(regex) {
|
|
58
|
-
return check;
|
|
59
|
-
function check(code) {
|
|
60
|
-
return null !== code && code > -1 && regex.test(String.fromCodePoint(code));
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
(function(constantsEx) {
|
|
64
|
-
constantsEx.spaceOrPunctuation = 3;
|
|
65
|
-
constantsEx.cjk = 0x1000;
|
|
66
|
-
constantsEx.cjkPunctuation = 0x1002;
|
|
67
|
-
constantsEx.ivs = 0x2000;
|
|
68
|
-
constantsEx.cjkOrIvs = 0x3000;
|
|
69
|
-
constantsEx.svsFollowingCjk = 0x4000;
|
|
70
|
-
constantsEx.variationSelector = 0x7000;
|
|
71
|
-
})(classifyCharacter_constantsEx || (classifyCharacter_constantsEx = {}));
|
|
72
|
-
function classifyCharacter(code) {
|
|
73
|
-
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;
|
|
74
|
-
let value = 0;
|
|
75
|
-
if (code >= 0x1100) {
|
|
76
|
-
if (svsFollowingCjk(code)) return classifyCharacter_constantsEx.svsFollowingCjk;
|
|
77
|
-
switch(cjkOrIvs(code)){
|
|
78
|
-
case null:
|
|
79
|
-
return classifyCharacter_constantsEx.ivs;
|
|
80
|
-
case true:
|
|
81
|
-
value |= classifyCharacter_constantsEx.cjk;
|
|
82
|
-
break;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
if (unicodePunctuation(code)) value |= external_micromark_util_symbol_namespaceObject.constants.characterGroupPunctuation;
|
|
86
|
-
return value;
|
|
87
|
-
}
|
|
88
|
-
var classifyCharacter_constantsEx;
|
|
89
|
-
const attention = {
|
|
90
|
-
name: "attention",
|
|
91
|
-
resolveAll: resolveAllAttention,
|
|
92
|
-
tokenize: tokenizeAttention
|
|
93
|
-
};
|
|
94
|
-
function resolveAllAttention(events, context) {
|
|
95
|
-
let index = -1;
|
|
96
|
-
let open;
|
|
97
|
-
let group;
|
|
98
|
-
let text;
|
|
99
|
-
let openingSequence;
|
|
100
|
-
let closingSequence;
|
|
101
|
-
let use;
|
|
102
|
-
let nextEvents;
|
|
103
|
-
let offset;
|
|
104
|
-
while(++index < events.length)if ("enter" === events[index][0] && "attentionSequence" === events[index][1].type && events[index][1]._close) {
|
|
105
|
-
open = index;
|
|
106
|
-
while(open--)if ("exit" === events[open][0] && "attentionSequence" === events[open][1].type && events[open][1]._open && context.sliceSerialize(events[open][1]).charCodeAt(0) === context.sliceSerialize(events[index][1]).charCodeAt(0)) {
|
|
107
|
-
if ((events[open][1]._close || events[index][1]._open) && (events[index][1].end.offset - events[index][1].start.offset) % 3 && !((events[open][1].end.offset - events[open][1].start.offset + events[index][1].end.offset - events[index][1].start.offset) % 3)) continue;
|
|
108
|
-
use = events[open][1].end.offset - events[open][1].start.offset > 1 && events[index][1].end.offset - events[index][1].start.offset > 1 ? 2 : 1;
|
|
109
|
-
const start = {
|
|
110
|
-
...events[open][1].end
|
|
111
|
-
};
|
|
112
|
-
const end = {
|
|
113
|
-
...events[index][1].start
|
|
114
|
-
};
|
|
115
|
-
movePoint(start, -use);
|
|
116
|
-
movePoint(end, use);
|
|
117
|
-
openingSequence = {
|
|
118
|
-
type: use > 1 ? external_micromark_util_symbol_namespaceObject.types.strongSequence : external_micromark_util_symbol_namespaceObject.types.emphasisSequence,
|
|
119
|
-
start,
|
|
120
|
-
end: {
|
|
121
|
-
...events[open][1].end
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
closingSequence = {
|
|
125
|
-
type: use > 1 ? external_micromark_util_symbol_namespaceObject.types.strongSequence : external_micromark_util_symbol_namespaceObject.types.emphasisSequence,
|
|
126
|
-
start: {
|
|
127
|
-
...events[index][1].start
|
|
128
|
-
},
|
|
129
|
-
end
|
|
130
|
-
};
|
|
131
|
-
text = {
|
|
132
|
-
type: use > 1 ? external_micromark_util_symbol_namespaceObject.types.strongText : external_micromark_util_symbol_namespaceObject.types.emphasisText,
|
|
133
|
-
start: {
|
|
134
|
-
...events[open][1].end
|
|
135
|
-
},
|
|
136
|
-
end: {
|
|
137
|
-
...events[index][1].start
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
group = {
|
|
141
|
-
type: use > 1 ? external_micromark_util_symbol_namespaceObject.types.strong : external_micromark_util_symbol_namespaceObject.types.emphasis,
|
|
142
|
-
start: {
|
|
143
|
-
...openingSequence.start
|
|
144
|
-
},
|
|
145
|
-
end: {
|
|
146
|
-
...closingSequence.end
|
|
147
|
-
}
|
|
148
|
-
};
|
|
149
|
-
events[open][1].end = {
|
|
150
|
-
...openingSequence.start
|
|
151
|
-
};
|
|
152
|
-
events[index][1].start = {
|
|
153
|
-
...closingSequence.end
|
|
154
|
-
};
|
|
155
|
-
nextEvents = [];
|
|
156
|
-
if (events[open][1].end.offset - events[open][1].start.offset) nextEvents = (0, external_micromark_util_chunked_namespaceObject.push)(nextEvents, [
|
|
157
|
-
[
|
|
158
|
-
"enter",
|
|
159
|
-
events[open][1],
|
|
160
|
-
context
|
|
161
|
-
],
|
|
162
|
-
[
|
|
163
|
-
"exit",
|
|
164
|
-
events[open][1],
|
|
165
|
-
context
|
|
166
|
-
]
|
|
167
|
-
]);
|
|
168
|
-
nextEvents = (0, external_micromark_util_chunked_namespaceObject.push)(nextEvents, [
|
|
169
|
-
[
|
|
170
|
-
"enter",
|
|
171
|
-
group,
|
|
172
|
-
context
|
|
173
|
-
],
|
|
174
|
-
[
|
|
175
|
-
"enter",
|
|
176
|
-
openingSequence,
|
|
177
|
-
context
|
|
178
|
-
],
|
|
179
|
-
[
|
|
180
|
-
"exit",
|
|
181
|
-
openingSequence,
|
|
182
|
-
context
|
|
183
|
-
],
|
|
184
|
-
[
|
|
185
|
-
"enter",
|
|
186
|
-
text,
|
|
187
|
-
context
|
|
188
|
-
]
|
|
189
|
-
]);
|
|
190
|
-
(0, external_devlop_namespaceObject.ok)(context.parser.constructs.insideSpan.null, "expected `insideSpan` to be populated");
|
|
191
|
-
nextEvents = (0, external_micromark_util_chunked_namespaceObject.push)(nextEvents, (0, external_micromark_util_resolve_all_namespaceObject.resolveAll)(context.parser.constructs.insideSpan.null, events.slice(open + 1, index), context));
|
|
192
|
-
nextEvents = (0, external_micromark_util_chunked_namespaceObject.push)(nextEvents, [
|
|
193
|
-
[
|
|
194
|
-
"exit",
|
|
195
|
-
text,
|
|
196
|
-
context
|
|
197
|
-
],
|
|
198
|
-
[
|
|
199
|
-
"enter",
|
|
200
|
-
closingSequence,
|
|
201
|
-
context
|
|
202
|
-
],
|
|
203
|
-
[
|
|
204
|
-
"exit",
|
|
205
|
-
closingSequence,
|
|
206
|
-
context
|
|
207
|
-
],
|
|
208
|
-
[
|
|
209
|
-
"exit",
|
|
210
|
-
group,
|
|
211
|
-
context
|
|
212
|
-
]
|
|
213
|
-
]);
|
|
214
|
-
if (events[index][1].end.offset - events[index][1].start.offset) {
|
|
215
|
-
offset = 2;
|
|
216
|
-
nextEvents = (0, external_micromark_util_chunked_namespaceObject.push)(nextEvents, [
|
|
217
|
-
[
|
|
218
|
-
"enter",
|
|
219
|
-
events[index][1],
|
|
220
|
-
context
|
|
221
|
-
],
|
|
222
|
-
[
|
|
223
|
-
"exit",
|
|
224
|
-
events[index][1],
|
|
225
|
-
context
|
|
226
|
-
]
|
|
227
|
-
]);
|
|
228
|
-
} else offset = 0;
|
|
229
|
-
(0, external_micromark_util_chunked_namespaceObject.splice)(events, open - 1, index - open + 3, nextEvents);
|
|
230
|
-
index = open + nextEvents.length - offset - 2;
|
|
231
|
-
break;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
index = -1;
|
|
235
|
-
while(++index < events.length)if ("attentionSequence" === events[index][1].type) events[index][1].type = "data";
|
|
236
|
-
return events;
|
|
237
|
-
}
|
|
238
|
-
function tokenizeAttention(effects, ok) {
|
|
239
|
-
const attentionMarkers = this.parser.constructs.attentionMarkers.null;
|
|
240
|
-
let previous = this.previous;
|
|
241
|
-
const { now, sliceSerialize } = this;
|
|
242
|
-
if (previous && previous >= 0xdc00 && previous <= 0xdfff) {
|
|
243
|
-
const nowPoint = now();
|
|
244
|
-
if (nowPoint._bufferIndex >= 2) {
|
|
245
|
-
const previousBuffer = sliceSerialize({
|
|
246
|
-
start: {
|
|
247
|
-
...nowPoint,
|
|
248
|
-
_bufferIndex: nowPoint._bufferIndex - 2
|
|
249
|
-
},
|
|
250
|
-
end: nowPoint
|
|
251
|
-
});
|
|
252
|
-
const previousCandidate = previousBuffer.codePointAt(0);
|
|
253
|
-
if (previousCandidate && previousCandidate >= 65536) previous = previousCandidate;
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
const before = classifyCharacter(previous);
|
|
257
|
-
let beforePrimary = before;
|
|
258
|
-
if (before === classifyCharacter_constantsEx.svsFollowingCjk) {
|
|
259
|
-
const nowPoint = now();
|
|
260
|
-
const previousWidth = previous >= 65536 ? 2 : 1;
|
|
261
|
-
if (nowPoint._bufferIndex >= 1 + previousWidth) {
|
|
262
|
-
const idealStart = nowPoint._bufferIndex - previousWidth - 2;
|
|
263
|
-
const twoPreviousBuffer = sliceSerialize({
|
|
264
|
-
start: {
|
|
265
|
-
...nowPoint,
|
|
266
|
-
_bufferIndex: idealStart >= 0 ? idealStart : 0
|
|
267
|
-
},
|
|
268
|
-
end: {
|
|
269
|
-
...nowPoint,
|
|
270
|
-
_bufferIndex: nowPoint._bufferIndex - previousWidth
|
|
271
|
-
}
|
|
272
|
-
});
|
|
273
|
-
const twoPreviousLast = twoPreviousBuffer.charCodeAt(twoPreviousBuffer.length - 1);
|
|
274
|
-
if (!Number.isNaN(twoPreviousLast)) {
|
|
275
|
-
let twoPrevious;
|
|
276
|
-
if (twoPreviousBuffer.length >= 2 && twoPreviousLast >= 0xdc00 && twoPreviousLast <= 0xdfff) {
|
|
277
|
-
const twoPreviousCandidate = twoPreviousBuffer.codePointAt(0);
|
|
278
|
-
twoPrevious = twoPreviousCandidate && twoPreviousCandidate >= 65536 ? twoPreviousCandidate : twoPreviousLast;
|
|
279
|
-
} else twoPrevious = twoPreviousLast;
|
|
280
|
-
beforePrimary = classifyCharacter(twoPrevious);
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
let marker;
|
|
285
|
-
return start;
|
|
286
|
-
function start(code) {
|
|
287
|
-
(0, external_devlop_namespaceObject.ok)(code === external_micromark_util_symbol_namespaceObject.codes.asterisk || code === external_micromark_util_symbol_namespaceObject.codes.underscore, "expected asterisk or underscore");
|
|
288
|
-
marker = code;
|
|
289
|
-
effects.enter("attentionSequence");
|
|
290
|
-
return inside(code);
|
|
291
|
-
}
|
|
292
|
-
function inside(code) {
|
|
293
|
-
if (code === marker) {
|
|
294
|
-
effects.consume(code);
|
|
295
|
-
return inside;
|
|
296
|
-
}
|
|
297
|
-
const token = effects.exit("attentionSequence");
|
|
298
|
-
let next = code;
|
|
299
|
-
if (next && next >= 0xd800 && next <= 0xdfff) {
|
|
300
|
-
const nowPoint = now();
|
|
301
|
-
const nextCandidate = sliceSerialize({
|
|
302
|
-
start: nowPoint,
|
|
303
|
-
end: {
|
|
304
|
-
...nowPoint,
|
|
305
|
-
_bufferIndex: nowPoint._bufferIndex + 2
|
|
306
|
-
}
|
|
307
|
-
}).codePointAt(0);
|
|
308
|
-
if (nextCandidate && nextCandidate >= 65536) next = nextCandidate;
|
|
309
|
-
}
|
|
310
|
-
const after = classifyCharacter(next);
|
|
311
|
-
(0, external_devlop_namespaceObject.ok)(attentionMarkers, "expected `attentionMarkers` to be populated");
|
|
312
|
-
const beforeNonCjkPunctuation = Boolean((before & classifyCharacter_constantsEx.cjkPunctuation) === external_micromark_util_symbol_namespaceObject.constants.characterGroupPunctuation);
|
|
313
|
-
const beforeSpaceOrNonCjkPunctuation = Boolean(beforeNonCjkPunctuation || before & external_micromark_util_symbol_namespaceObject.constants.characterGroupWhitespace);
|
|
314
|
-
const afterNonCjkPunctuation = Boolean((after & classifyCharacter_constantsEx.cjkPunctuation) === external_micromark_util_symbol_namespaceObject.constants.characterGroupPunctuation);
|
|
315
|
-
const afterSpaceOrNonCjkPunctuation = Boolean(afterNonCjkPunctuation || after & external_micromark_util_symbol_namespaceObject.constants.characterGroupWhitespace);
|
|
316
|
-
const beforeCjkOrIvs = Boolean(beforePrimary & classifyCharacter_constantsEx.cjk || before & classifyCharacter_constantsEx.ivs);
|
|
317
|
-
const open = Boolean(!afterSpaceOrNonCjkPunctuation || afterNonCjkPunctuation && (beforeSpaceOrNonCjkPunctuation || beforeCjkOrIvs) || attentionMarkers.includes(code));
|
|
318
|
-
const close = Boolean(!beforeSpaceOrNonCjkPunctuation || beforeNonCjkPunctuation && (afterSpaceOrNonCjkPunctuation || after & classifyCharacter_constantsEx.cjk) || attentionMarkers.includes(previous));
|
|
319
|
-
token._open = Boolean(marker === external_micromark_util_symbol_namespaceObject.codes.asterisk ? open : open && (before & classifyCharacter_constantsEx.spaceOrPunctuation || !close));
|
|
320
|
-
token._close = Boolean(marker === external_micromark_util_symbol_namespaceObject.codes.asterisk ? close : close && (after & classifyCharacter_constantsEx.spaceOrPunctuation || !open));
|
|
321
|
-
return ok(code);
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
function movePoint(point, offset) {
|
|
325
|
-
point.column += offset;
|
|
326
|
-
point.offset += offset;
|
|
327
|
-
point._bufferIndex += offset;
|
|
328
|
-
}
|
|
329
|
-
function cjkFriendlyExtension() {
|
|
330
|
-
return {
|
|
331
|
-
text: {
|
|
332
|
-
[external_micromark_util_symbol_namespaceObject.codes.asterisk]: attention,
|
|
333
|
-
[external_micromark_util_symbol_namespaceObject.codes.underscore]: attention
|
|
334
|
-
},
|
|
335
|
-
insideSpan: {
|
|
336
|
-
null: [
|
|
337
|
-
attention
|
|
338
|
-
]
|
|
339
|
-
}
|
|
340
|
-
};
|
|
341
|
-
}
|
|
342
|
-
var __webpack_export_target__ = exports;
|
|
343
|
-
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
344
|
-
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
|
|
345
|
-
value: true
|
|
346
|
-
});
|