micromark-extension-cjk-friendly 1.1.0 → 1.2.0-rc.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/dist/ext/attention.d.ts +2 -14
- package/dist/ext/attention.js +8 -6
- package/dist/index.js +8 -6
- package/package.json +2 -2
package/dist/ext/attention.d.ts
CHANGED
|
@@ -1,17 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Construct } from 'micromark-util-types';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
declare const attention: {
|
|
5
|
-
name: string;
|
|
6
|
-
resolveAll: typeof resolveAllAttention;
|
|
7
|
-
tokenize: typeof tokenizeAttention;
|
|
8
|
-
};
|
|
9
|
-
declare function resolveAllAttention(events: Parameters<Resolver>[0], context: Parameters<Resolver>[1]): ReturnType<Resolver>;
|
|
10
|
-
/**
|
|
11
|
-
* @this {TokenizeContext}
|
|
12
|
-
* Context.
|
|
13
|
-
* @type {Tokenizer}
|
|
14
|
-
*/
|
|
15
|
-
declare function tokenizeAttention(this: TokenizeContext, effects: Effects, ok: State): State;
|
|
3
|
+
declare const attention: Construct;
|
|
16
4
|
|
|
17
5
|
export { attention };
|
package/dist/ext/attention.js
CHANGED
|
@@ -7,8 +7,8 @@ import {
|
|
|
7
7
|
isCodeLowSurrogate,
|
|
8
8
|
isIvs,
|
|
9
9
|
isNonCjkPunctuation,
|
|
10
|
+
isNonEmojiGeneralUseVS,
|
|
10
11
|
isSpaceOrPunctuation,
|
|
11
|
-
isSvsFollowingCjk,
|
|
12
12
|
isUnicodeWhitespace,
|
|
13
13
|
tryGetCodeTwoBefore,
|
|
14
14
|
tryGetGenuineNextCode,
|
|
@@ -132,14 +132,16 @@ function tokenizeAttention(effects, ok) {
|
|
|
132
132
|
) : tentativePrevious;
|
|
133
133
|
const before = classifyCharacter(previous);
|
|
134
134
|
let beforePrimary = before;
|
|
135
|
-
if (
|
|
135
|
+
if (isNonEmojiGeneralUseVS(before)) {
|
|
136
136
|
const twoPrevious = tryGetCodeTwoBefore(
|
|
137
137
|
// biome-ignore lint/style/noNonNullAssertion: if `previous` were null, before would be `undefined`
|
|
138
138
|
previous,
|
|
139
139
|
now(),
|
|
140
140
|
sliceSerialize
|
|
141
141
|
);
|
|
142
|
-
if (twoPrevious !== null)
|
|
142
|
+
if (twoPrevious !== null) {
|
|
143
|
+
beforePrimary = classifyCharacter(twoPrevious);
|
|
144
|
+
}
|
|
143
145
|
}
|
|
144
146
|
let marker;
|
|
145
147
|
return start;
|
|
@@ -161,15 +163,15 @@ function tokenizeAttention(effects, ok) {
|
|
|
161
163
|
const next = isCodeHighSurrogate(code) ? tryGetGenuineNextCode(code, now(), sliceSerialize) : code;
|
|
162
164
|
const after = classifyCharacter(next);
|
|
163
165
|
assert(attentionMarkers, "expected `attentionMarkers` to be populated");
|
|
164
|
-
const beforeNonCjkPunctuation = isNonCjkPunctuation(
|
|
165
|
-
const beforeSpaceOrNonCjkPunctuation = beforeNonCjkPunctuation || isUnicodeWhitespace(
|
|
166
|
+
const beforeNonCjkPunctuation = isNonCjkPunctuation(beforePrimary);
|
|
167
|
+
const beforeSpaceOrNonCjkPunctuation = beforeNonCjkPunctuation || isUnicodeWhitespace(beforePrimary);
|
|
166
168
|
const afterNonCjkPunctuation = isNonCjkPunctuation(after);
|
|
167
169
|
const afterSpaceOrNonCjkPunctuation = afterNonCjkPunctuation || isUnicodeWhitespace(after);
|
|
168
170
|
const beforeCjkOrIvs = isCjk(beforePrimary) || isIvs(before);
|
|
169
171
|
const open = !afterSpaceOrNonCjkPunctuation || afterNonCjkPunctuation && (beforeSpaceOrNonCjkPunctuation || beforeCjkOrIvs) || attentionMarkers.includes(code);
|
|
170
172
|
const close = !beforeSpaceOrNonCjkPunctuation || beforeNonCjkPunctuation && (afterSpaceOrNonCjkPunctuation || isCjk(after)) || attentionMarkers.includes(previous);
|
|
171
173
|
token._open = Boolean(
|
|
172
|
-
marker === codes.asterisk ? open : open && (isSpaceOrPunctuation(
|
|
174
|
+
marker === codes.asterisk ? open : open && (isSpaceOrPunctuation(beforePrimary) || !close)
|
|
173
175
|
);
|
|
174
176
|
token._close = Boolean(
|
|
175
177
|
marker === codes.asterisk ? close : close && (isSpaceOrPunctuation(after) || !open)
|
package/dist/index.js
CHANGED
|
@@ -10,8 +10,8 @@ import {
|
|
|
10
10
|
isCodeLowSurrogate,
|
|
11
11
|
isIvs,
|
|
12
12
|
isNonCjkPunctuation,
|
|
13
|
+
isNonEmojiGeneralUseVS,
|
|
13
14
|
isSpaceOrPunctuation,
|
|
14
|
-
isSvsFollowingCjk,
|
|
15
15
|
isUnicodeWhitespace,
|
|
16
16
|
tryGetCodeTwoBefore,
|
|
17
17
|
tryGetGenuineNextCode,
|
|
@@ -135,14 +135,16 @@ function tokenizeAttention(effects, ok) {
|
|
|
135
135
|
) : tentativePrevious;
|
|
136
136
|
const before = classifyCharacter(previous);
|
|
137
137
|
let beforePrimary = before;
|
|
138
|
-
if (
|
|
138
|
+
if (isNonEmojiGeneralUseVS(before)) {
|
|
139
139
|
const twoPrevious = tryGetCodeTwoBefore(
|
|
140
140
|
// biome-ignore lint/style/noNonNullAssertion: if `previous` were null, before would be `undefined`
|
|
141
141
|
previous,
|
|
142
142
|
now(),
|
|
143
143
|
sliceSerialize
|
|
144
144
|
);
|
|
145
|
-
if (twoPrevious !== null)
|
|
145
|
+
if (twoPrevious !== null) {
|
|
146
|
+
beforePrimary = classifyCharacter(twoPrevious);
|
|
147
|
+
}
|
|
146
148
|
}
|
|
147
149
|
let marker;
|
|
148
150
|
return start;
|
|
@@ -164,15 +166,15 @@ function tokenizeAttention(effects, ok) {
|
|
|
164
166
|
const next = isCodeHighSurrogate(code) ? tryGetGenuineNextCode(code, now(), sliceSerialize) : code;
|
|
165
167
|
const after = classifyCharacter(next);
|
|
166
168
|
assert(attentionMarkers, "expected `attentionMarkers` to be populated");
|
|
167
|
-
const beforeNonCjkPunctuation = isNonCjkPunctuation(
|
|
168
|
-
const beforeSpaceOrNonCjkPunctuation = beforeNonCjkPunctuation || isUnicodeWhitespace(
|
|
169
|
+
const beforeNonCjkPunctuation = isNonCjkPunctuation(beforePrimary);
|
|
170
|
+
const beforeSpaceOrNonCjkPunctuation = beforeNonCjkPunctuation || isUnicodeWhitespace(beforePrimary);
|
|
169
171
|
const afterNonCjkPunctuation = isNonCjkPunctuation(after);
|
|
170
172
|
const afterSpaceOrNonCjkPunctuation = afterNonCjkPunctuation || isUnicodeWhitespace(after);
|
|
171
173
|
const beforeCjkOrIvs = isCjk(beforePrimary) || isIvs(before);
|
|
172
174
|
const open = !afterSpaceOrNonCjkPunctuation || afterNonCjkPunctuation && (beforeSpaceOrNonCjkPunctuation || beforeCjkOrIvs) || attentionMarkers.includes(code);
|
|
173
175
|
const close = !beforeSpaceOrNonCjkPunctuation || beforeNonCjkPunctuation && (afterSpaceOrNonCjkPunctuation || isCjk(after)) || attentionMarkers.includes(previous);
|
|
174
176
|
token._open = Boolean(
|
|
175
|
-
marker === codes.asterisk ? open : open && (isSpaceOrPunctuation(
|
|
177
|
+
marker === codes.asterisk ? open : open && (isSpaceOrPunctuation(beforePrimary) || !close)
|
|
176
178
|
);
|
|
177
179
|
token._close = Boolean(
|
|
178
180
|
marker === codes.asterisk ? close : close && (isSpaceOrPunctuation(after) || !open)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "micromark-extension-cjk-friendly",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0-rc.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"micromark-util-chunked": "^2.0.0",
|
|
38
38
|
"micromark-util-resolve-all": "^2.0.0",
|
|
39
39
|
"micromark-util-symbol": "^2.0.0",
|
|
40
|
-
"micromark-extension-cjk-friendly-util": "^
|
|
40
|
+
"micromark-extension-cjk-friendly-util": "^2.0.0-rc.1"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"micromark": "^4.0.1",
|