micromark-extension-cjk-friendly 1.2.0-rc.1 → 1.2.0-rc.2

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.
@@ -2,18 +2,18 @@
2
2
  import { ok as assert } from "devlop";
3
3
  import {
4
4
  classifyCharacter,
5
+ classifyPrecedingCharacter,
5
6
  isCjk,
7
+ isCjkOrIvs,
6
8
  isCodeHighSurrogate,
7
9
  isCodeLowSurrogate,
8
- isIvs,
9
10
  isNonCjkPunctuation,
10
- isNonEmojiGeneralUseVS,
11
11
  isSpaceOrPunctuation,
12
12
  isUnicodeWhitespace,
13
- tryGetCodeTwoBefore,
14
13
  tryGetGenuineNextCode,
15
14
  tryGetGenuinePreviousCode
16
15
  } from "micromark-extension-cjk-friendly-util";
16
+ import { TwoPreviousCode } from "micromark-extension-cjk-friendly-util";
17
17
  import { push, splice } from "micromark-util-chunked";
18
18
  import { resolveAll } from "micromark-util-resolve-all";
19
19
  import { codes, types } from "micromark-util-symbol";
@@ -131,18 +131,12 @@ function tokenizeAttention(effects, ok) {
131
131
  tryGetGenuinePreviousCode(tentativePrevious, now(), sliceSerialize)
132
132
  ) : tentativePrevious;
133
133
  const before = classifyCharacter(previous);
134
- let beforePrimary = before;
135
- if (isNonEmojiGeneralUseVS(before)) {
136
- const twoPrevious = tryGetCodeTwoBefore(
137
- // biome-ignore lint/style/noNonNullAssertion: if `previous` were null, before would be `undefined`
138
- previous,
139
- now(),
140
- sliceSerialize
141
- );
142
- if (twoPrevious !== null) {
143
- beforePrimary = classifyCharacter(twoPrevious);
144
- }
145
- }
134
+ const twoPrevious = new TwoPreviousCode(previous, now(), sliceSerialize);
135
+ const beforePrimary = classifyPrecedingCharacter(
136
+ before,
137
+ twoPrevious.value.bind(twoPrevious),
138
+ previous
139
+ );
146
140
  let marker;
147
141
  return start;
148
142
  function start(code) {
@@ -167,7 +161,7 @@ function tokenizeAttention(effects, ok) {
167
161
  const beforeSpaceOrNonCjkPunctuation = beforeNonCjkPunctuation || isUnicodeWhitespace(beforePrimary);
168
162
  const afterNonCjkPunctuation = isNonCjkPunctuation(after);
169
163
  const afterSpaceOrNonCjkPunctuation = afterNonCjkPunctuation || isUnicodeWhitespace(after);
170
- const beforeCjkOrIvs = isCjk(beforePrimary) || isIvs(before);
164
+ const beforeCjkOrIvs = isCjkOrIvs(beforePrimary);
171
165
  const open = !afterSpaceOrNonCjkPunctuation || afterNonCjkPunctuation && (beforeSpaceOrNonCjkPunctuation || beforeCjkOrIvs) || attentionMarkers.includes(code);
172
166
  const close = !beforeSpaceOrNonCjkPunctuation || beforeNonCjkPunctuation && (afterSpaceOrNonCjkPunctuation || isCjk(after)) || attentionMarkers.includes(previous);
173
167
  token._open = Boolean(
package/dist/index.js CHANGED
@@ -5,18 +5,18 @@ import { codes as codes2 } from "micromark-util-symbol";
5
5
  import { ok as assert } from "devlop";
6
6
  import {
7
7
  classifyCharacter,
8
+ classifyPrecedingCharacter,
8
9
  isCjk,
10
+ isCjkOrIvs,
9
11
  isCodeHighSurrogate,
10
12
  isCodeLowSurrogate,
11
- isIvs,
12
13
  isNonCjkPunctuation,
13
- isNonEmojiGeneralUseVS,
14
14
  isSpaceOrPunctuation,
15
15
  isUnicodeWhitespace,
16
- tryGetCodeTwoBefore,
17
16
  tryGetGenuineNextCode,
18
17
  tryGetGenuinePreviousCode
19
18
  } from "micromark-extension-cjk-friendly-util";
19
+ import { TwoPreviousCode } from "micromark-extension-cjk-friendly-util";
20
20
  import { push, splice } from "micromark-util-chunked";
21
21
  import { resolveAll } from "micromark-util-resolve-all";
22
22
  import { codes, types } from "micromark-util-symbol";
@@ -134,18 +134,12 @@ function tokenizeAttention(effects, ok) {
134
134
  tryGetGenuinePreviousCode(tentativePrevious, now(), sliceSerialize)
135
135
  ) : tentativePrevious;
136
136
  const before = classifyCharacter(previous);
137
- let beforePrimary = before;
138
- if (isNonEmojiGeneralUseVS(before)) {
139
- const twoPrevious = tryGetCodeTwoBefore(
140
- // biome-ignore lint/style/noNonNullAssertion: if `previous` were null, before would be `undefined`
141
- previous,
142
- now(),
143
- sliceSerialize
144
- );
145
- if (twoPrevious !== null) {
146
- beforePrimary = classifyCharacter(twoPrevious);
147
- }
148
- }
137
+ const twoPrevious = new TwoPreviousCode(previous, now(), sliceSerialize);
138
+ const beforePrimary = classifyPrecedingCharacter(
139
+ before,
140
+ twoPrevious.value.bind(twoPrevious),
141
+ previous
142
+ );
149
143
  let marker;
150
144
  return start;
151
145
  function start(code) {
@@ -170,7 +164,7 @@ function tokenizeAttention(effects, ok) {
170
164
  const beforeSpaceOrNonCjkPunctuation = beforeNonCjkPunctuation || isUnicodeWhitespace(beforePrimary);
171
165
  const afterNonCjkPunctuation = isNonCjkPunctuation(after);
172
166
  const afterSpaceOrNonCjkPunctuation = afterNonCjkPunctuation || isUnicodeWhitespace(after);
173
- const beforeCjkOrIvs = isCjk(beforePrimary) || isIvs(before);
167
+ const beforeCjkOrIvs = isCjkOrIvs(beforePrimary);
174
168
  const open = !afterSpaceOrNonCjkPunctuation || afterNonCjkPunctuation && (beforeSpaceOrNonCjkPunctuation || beforeCjkOrIvs) || attentionMarkers.includes(code);
175
169
  const close = !beforeSpaceOrNonCjkPunctuation || beforeNonCjkPunctuation && (afterSpaceOrNonCjkPunctuation || isCjk(after)) || attentionMarkers.includes(previous);
176
170
  token._open = Boolean(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "micromark-extension-cjk-friendly",
3
- "version": "1.2.0-rc.1",
3
+ "version": "1.2.0-rc.2",
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": "^2.0.0-rc.1"
40
+ "micromark-extension-cjk-friendly-util": "^2.0.0-rc.2"
41
41
  },
42
42
  "devDependencies": {
43
43
  "micromark": "^4.0.1",