@yozora/tokenizer-inline-math 2.3.10 → 2.3.11
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/CHANGELOG.md +8 -0
- package/README.md +42 -42
- package/lib/cjs/index.cjs +35 -33
- package/lib/esm/index.mjs +35 -34
- package/lib/types/index.d.ts +3 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## <small>2.3.11 (2025-01-13)</small>
|
|
7
|
+
|
|
8
|
+
* improve(inline-math): the inline dollars should take high processing priority so the delimiter bound ([3dba582](https://github.com/yozorajs/yozora/commit/3dba582))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
## <small>2.3.10 (2025-01-09)</small>
|
|
7
15
|
|
|
8
16
|
* chore: fix nx dependencies ([d11d405](https://github.com/yozorajs/yozora/commit/d11d405))
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
<header>
|
|
4
4
|
<h1 align="center">
|
|
5
|
-
<a href="https://github.com/yozorajs/yozora/tree/v2.3.
|
|
5
|
+
<a href="https://github.com/yozorajs/yozora/tree/v2.3.11/tokenizers/inline-math#readme">@yozora/tokenizer-inline-math</a>
|
|
6
6
|
</h1>
|
|
7
7
|
<div align="center">
|
|
8
8
|
<a href="https://www.npmjs.com/package/@yozora/tokenizer-inline-math">
|
|
@@ -181,80 +181,80 @@ parser.parse("`$x^2 + y^2 = z^2, x < 0$`")
|
|
|
181
181
|
|
|
182
182
|
[live-examples]: https://yozora.guanghechen.com/docs/package/tokenizer-inline-math#live-examples
|
|
183
183
|
[docpage]: https://yozora.guanghechen.com/docs/package/tokenizer-inline-math
|
|
184
|
-
[homepage]: https://github.com/yozorajs/yozora/tree/v2.3.
|
|
184
|
+
[homepage]: https://github.com/yozorajs/yozora/tree/v2.3.11/tokenizers/inline-math#readme
|
|
185
185
|
[gfm-spec]: https://github.github.com/gfm
|
|
186
186
|
[mdast-homepage]: https://github.com/syntax-tree/mdast
|
|
187
|
-
[@yozora/ast]: https://github.com/yozorajs/yozora/tree/v2.3.
|
|
188
|
-
[@yozora/ast-util]: https://github.com/yozorajs/yozora/tree/v2.3.
|
|
189
|
-
[@yozora/character]: https://github.com/yozorajs/yozora/tree/v2.3.
|
|
187
|
+
[@yozora/ast]: https://github.com/yozorajs/yozora/tree/v2.3.11/packages/ast#readme
|
|
188
|
+
[@yozora/ast-util]: https://github.com/yozorajs/yozora/tree/v2.3.11/packages/ast-util#readme
|
|
189
|
+
[@yozora/character]: https://github.com/yozorajs/yozora/tree/v2.3.11/packages/character#readme
|
|
190
190
|
[@yozora/eslint-config]:
|
|
191
191
|
https://github.com/yozorajs/yozora/tree/release-2.x.x/packages/eslint-config#readme
|
|
192
|
-
[@yozora/core-parser]: https://github.com/yozorajs/yozora/tree/v2.3.
|
|
192
|
+
[@yozora/core-parser]: https://github.com/yozorajs/yozora/tree/v2.3.11/packages/core-parser#readme
|
|
193
193
|
[@yozora/core-tokenizer]:
|
|
194
|
-
https://github.com/yozorajs/yozora/tree/v2.3.
|
|
195
|
-
[@yozora/invariant]: https://github.com/yozorajs/yozora/tree/v2.3.
|
|
194
|
+
https://github.com/yozorajs/yozora/tree/v2.3.11/packages/core-tokenizer#readme
|
|
195
|
+
[@yozora/invariant]: https://github.com/yozorajs/yozora/tree/v2.3.11/packages/invariant#readme
|
|
196
196
|
[@yozora/jest-for-tokenizer]:
|
|
197
197
|
https://github.com/yozorajs/yozora/tree/release-2.x.x/packages/jest-for-tokenizer#readme
|
|
198
|
-
[@yozora/parser]: https://github.com/yozorajs/yozora/tree/v2.3.
|
|
199
|
-
[@yozora/parser-gfm]: https://github.com/yozorajs/yozora/tree/v2.3.
|
|
198
|
+
[@yozora/parser]: https://github.com/yozorajs/yozora/tree/v2.3.11/packages/parser#readme
|
|
199
|
+
[@yozora/parser-gfm]: https://github.com/yozorajs/yozora/tree/v2.3.11/packages/parser-gfm#readme
|
|
200
200
|
[@yozora/parser-gfm-ex]:
|
|
201
|
-
https://github.com/yozorajs/yozora/tree/v2.3.
|
|
201
|
+
https://github.com/yozorajs/yozora/tree/v2.3.11/packages/parser-gfm-ex#readme
|
|
202
202
|
[@yozora/template-tokenizer]:
|
|
203
203
|
https://github.com/yozorajs/yozora/tree/release-2.x.x/packages/template-tokenizer#readme
|
|
204
204
|
[@yozora/tokenizer-admonition]:
|
|
205
|
-
https://github.com/yozorajs/yozora/tree/v2.3.
|
|
205
|
+
https://github.com/yozorajs/yozora/tree/v2.3.11/tokenizers/admonition#readme
|
|
206
206
|
[@yozora/tokenizer-autolink]:
|
|
207
|
-
https://github.com/yozorajs/yozora/tree/v2.3.
|
|
207
|
+
https://github.com/yozorajs/yozora/tree/v2.3.11/tokenizers/autolink#readme
|
|
208
208
|
[@yozora/tokenizer-autolink-extension]:
|
|
209
|
-
https://github.com/yozorajs/yozora/tree/v2.3.
|
|
209
|
+
https://github.com/yozorajs/yozora/tree/v2.3.11/tokenizers/autolink-extension#readme
|
|
210
210
|
[@yozora/tokenizer-blockquote]:
|
|
211
|
-
https://github.com/yozorajs/yozora/tree/v2.3.
|
|
212
|
-
[@yozora/tokenizer-break]: https://github.com/yozorajs/yozora/tree/v2.3.
|
|
211
|
+
https://github.com/yozorajs/yozora/tree/v2.3.11/tokenizers/blockquote#readme
|
|
212
|
+
[@yozora/tokenizer-break]: https://github.com/yozorajs/yozora/tree/v2.3.11/tokenizers/break#readme
|
|
213
213
|
[@yozora/tokenizer-definition]:
|
|
214
|
-
https://github.com/yozorajs/yozora/tree/v2.3.
|
|
215
|
-
[@yozora/tokenizer-delete]: https://github.com/yozorajs/yozora/tree/v2.3.
|
|
214
|
+
https://github.com/yozorajs/yozora/tree/v2.3.11/tokenizers/definition#readme
|
|
215
|
+
[@yozora/tokenizer-delete]: https://github.com/yozorajs/yozora/tree/v2.3.11/tokenizers/delete#readme
|
|
216
216
|
[@yozora/tokenizer-ecma-import]:
|
|
217
|
-
https://github.com/yozorajs/yozora/tree/v2.3.
|
|
217
|
+
https://github.com/yozorajs/yozora/tree/v2.3.11/tokenizers/ecma-import#readme
|
|
218
218
|
[@yozora/tokenizer-emphasis]:
|
|
219
|
-
https://github.com/yozorajs/yozora/tree/v2.3.
|
|
219
|
+
https://github.com/yozorajs/yozora/tree/v2.3.11/tokenizers/emphasis#readme
|
|
220
220
|
[@yozora/tokenizer-fenced-block]:
|
|
221
|
-
https://github.com/yozorajs/yozora/tree/v2.3.
|
|
221
|
+
https://github.com/yozorajs/yozora/tree/v2.3.11/tokenizers/fenced-block#readme
|
|
222
222
|
[@yozora/tokenizer-fenced-code]:
|
|
223
|
-
https://github.com/yozorajs/yozora/tree/v2.3.
|
|
223
|
+
https://github.com/yozorajs/yozora/tree/v2.3.11/tokenizers/fenced-code#readme
|
|
224
224
|
[@yozora/tokenizer-footnote]:
|
|
225
|
-
https://github.com/yozorajs/yozora/tree/v2.3.
|
|
225
|
+
https://github.com/yozorajs/yozora/tree/v2.3.11/tokenizers/footnote#readme
|
|
226
226
|
[@yozora/tokenizer-footnote-definition]:
|
|
227
|
-
https://github.com/yozorajs/yozora/tree/v2.3.
|
|
227
|
+
https://github.com/yozorajs/yozora/tree/v2.3.11/tokenizers/footnote-definition#readme
|
|
228
228
|
[@yozora/tokenizer-footnote-reference]:
|
|
229
|
-
https://github.com/yozorajs/yozora/tree/v2.3.
|
|
229
|
+
https://github.com/yozorajs/yozora/tree/v2.3.11/tokenizers/footnote-reference#readme
|
|
230
230
|
[@yozora/tokenizer-heading]:
|
|
231
|
-
https://github.com/yozorajs/yozora/tree/v2.3.
|
|
231
|
+
https://github.com/yozorajs/yozora/tree/v2.3.11/tokenizers/heading#readme
|
|
232
232
|
[@yozora/tokenizer-html-block]:
|
|
233
|
-
https://github.com/yozorajs/yozora/tree/v2.3.
|
|
233
|
+
https://github.com/yozorajs/yozora/tree/v2.3.11/tokenizers/html-block#readme
|
|
234
234
|
[@yozora/tokenizer-html-inline]:
|
|
235
|
-
https://github.com/yozorajs/yozora/tree/v2.3.
|
|
236
|
-
[@yozora/tokenizer-image]: https://github.com/yozorajs/yozora/tree/v2.3.
|
|
235
|
+
https://github.com/yozorajs/yozora/tree/v2.3.11/tokenizers/html-inline#readme
|
|
236
|
+
[@yozora/tokenizer-image]: https://github.com/yozorajs/yozora/tree/v2.3.11/tokenizers/image#readme
|
|
237
237
|
[@yozora/tokenizer-image-reference]:
|
|
238
|
-
https://github.com/yozorajs/yozora/tree/v2.3.
|
|
238
|
+
https://github.com/yozorajs/yozora/tree/v2.3.11/tokenizers/image-reference#readme
|
|
239
239
|
[@yozora/tokenizer-indented-code]:
|
|
240
|
-
https://github.com/yozorajs/yozora/tree/v2.3.
|
|
240
|
+
https://github.com/yozorajs/yozora/tree/v2.3.11/tokenizers/indented-code#readme
|
|
241
241
|
[@yozora/tokenizer-inline-code]:
|
|
242
|
-
https://github.com/yozorajs/yozora/tree/v2.3.
|
|
242
|
+
https://github.com/yozorajs/yozora/tree/v2.3.11/tokenizers/inline-code#readme
|
|
243
243
|
[@yozora/tokenizer-inline-math]:
|
|
244
|
-
https://github.com/yozorajs/yozora/tree/v2.3.
|
|
245
|
-
[@yozora/tokenizer-link]: https://github.com/yozorajs/yozora/tree/v2.3.
|
|
244
|
+
https://github.com/yozorajs/yozora/tree/v2.3.11/tokenizers/inline-math#readme
|
|
245
|
+
[@yozora/tokenizer-link]: https://github.com/yozorajs/yozora/tree/v2.3.11/tokenizers/link#readme
|
|
246
246
|
[@yozora/tokenizer-link-reference]:
|
|
247
|
-
https://github.com/yozorajs/yozora/tree/v2.3.
|
|
248
|
-
[@yozora/tokenizer-list]: https://github.com/yozorajs/yozora/tree/v2.3.
|
|
249
|
-
[@yozora/tokenizer-math]: https://github.com/yozorajs/yozora/tree/v2.3.
|
|
247
|
+
https://github.com/yozorajs/yozora/tree/v2.3.11/tokenizers/link-reference#readme
|
|
248
|
+
[@yozora/tokenizer-list]: https://github.com/yozorajs/yozora/tree/v2.3.11/tokenizers/list#readme
|
|
249
|
+
[@yozora/tokenizer-math]: https://github.com/yozorajs/yozora/tree/v2.3.11/tokenizers/math#readme
|
|
250
250
|
[@yozora/tokenizer-paragraph]:
|
|
251
|
-
https://github.com/yozorajs/yozora/tree/v2.3.
|
|
251
|
+
https://github.com/yozorajs/yozora/tree/v2.3.11/tokenizers/paragraph#readme
|
|
252
252
|
[@yozora/tokenizer-setext-heading]:
|
|
253
|
-
https://github.com/yozorajs/yozora/tree/v2.3.
|
|
254
|
-
[@yozora/tokenizer-table]: https://github.com/yozorajs/yozora/tree/v2.3.
|
|
255
|
-
[@yozora/tokenizer-text]: https://github.com/yozorajs/yozora/tree/v2.3.
|
|
253
|
+
https://github.com/yozorajs/yozora/tree/v2.3.11/tokenizers/setext-heading#readme
|
|
254
|
+
[@yozora/tokenizer-table]: https://github.com/yozorajs/yozora/tree/v2.3.11/tokenizers/table#readme
|
|
255
|
+
[@yozora/tokenizer-text]: https://github.com/yozorajs/yozora/tree/v2.3.11/tokenizers/text#readme
|
|
256
256
|
[@yozora/tokenizer-thematic-break]:
|
|
257
|
-
https://github.com/yozorajs/yozora/tree/v2.3.
|
|
257
|
+
https://github.com/yozorajs/yozora/tree/v2.3.11/tokenizers/thematic-break#readme
|
|
258
258
|
[@yozora/react-admonition]:
|
|
259
259
|
https://github.com/yozorajs/yozora-react/tree/main/packages/admonition#readme
|
|
260
260
|
[@yozora/react-blockquote]:
|
package/lib/cjs/index.cjs
CHANGED
|
@@ -27,8 +27,9 @@ const match = function (api) {
|
|
|
27
27
|
const leftCodePoint = i === blockStartIndex ? null : nodePoints[i - 1].codePoint;
|
|
28
28
|
i = coreTokenizer.eatOptionalCharacters(nodePoints, i + 1, blockEndIndex, character.AsciiCodePoint.DOLLAR_SIGN);
|
|
29
29
|
const rightCodePoint = i === blockEndIndex ? null : nodePoints[i].codePoint;
|
|
30
|
-
const
|
|
31
|
-
const
|
|
30
|
+
const thickness = i - _startIndex;
|
|
31
|
+
const isPotentialOpener = thickness > 1 || checkIfPotentialOpener(leftCodePoint, rightCodePoint);
|
|
32
|
+
const isPotentialCloser = thickness > 1 || checkIfPotentialCloser(leftCodePoint, rightCodePoint);
|
|
32
33
|
if (!isPotentialOpener && !isPotentialCloser)
|
|
33
34
|
break;
|
|
34
35
|
const delimiterType = isPotentialOpener
|
|
@@ -40,7 +41,7 @@ const match = function (api) {
|
|
|
40
41
|
type: delimiterType,
|
|
41
42
|
startIndex: _startIndex,
|
|
42
43
|
endIndex: i,
|
|
43
|
-
thickness
|
|
44
|
+
thickness,
|
|
44
45
|
};
|
|
45
46
|
return delimiter;
|
|
46
47
|
}
|
|
@@ -85,36 +86,6 @@ function processDelimiterPair(openerDelimiter, closerDelimiter) {
|
|
|
85
86
|
return { tokens: [token] };
|
|
86
87
|
}
|
|
87
88
|
|
|
88
|
-
const parse = function (api) {
|
|
89
|
-
return {
|
|
90
|
-
parse: tokens => tokens.map(token => {
|
|
91
|
-
const nodePoints = api.getNodePoints();
|
|
92
|
-
let startIndex = token.startIndex + token.thickness;
|
|
93
|
-
let endIndex = token.endIndex - token.thickness;
|
|
94
|
-
let isAllSpace = true;
|
|
95
|
-
for (let i = startIndex; i < endIndex; ++i) {
|
|
96
|
-
if (character.isSpaceLike(nodePoints[i].codePoint))
|
|
97
|
-
continue;
|
|
98
|
-
isAllSpace = false;
|
|
99
|
-
break;
|
|
100
|
-
}
|
|
101
|
-
if (!isAllSpace && startIndex + 2 < endIndex) {
|
|
102
|
-
const firstCharacter = nodePoints[startIndex].codePoint;
|
|
103
|
-
const lastCharacter = nodePoints[endIndex - 1].codePoint;
|
|
104
|
-
if (character.isSpaceLike(firstCharacter) && character.isSpaceLike(lastCharacter)) {
|
|
105
|
-
startIndex += 1;
|
|
106
|
-
endIndex -= 1;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
const value = character.calcStringFromNodePoints(nodePoints, startIndex, endIndex).replace(/\n/g, ' ');
|
|
110
|
-
const node = api.shouldReservePosition
|
|
111
|
-
? { type: ast.InlineMathType, position: api.calcPosition(token), value }
|
|
112
|
-
: { type: ast.InlineMathType, value };
|
|
113
|
-
return node;
|
|
114
|
-
}),
|
|
115
|
-
};
|
|
116
|
-
};
|
|
117
|
-
|
|
118
89
|
const matchWithBacktick = function (api) {
|
|
119
90
|
return { findDelimiter, processSingleDelimiter };
|
|
120
91
|
function* findDelimiter() {
|
|
@@ -216,6 +187,36 @@ const matchWithBacktick = function (api) {
|
|
|
216
187
|
}
|
|
217
188
|
};
|
|
218
189
|
|
|
190
|
+
const parse = function (api) {
|
|
191
|
+
return {
|
|
192
|
+
parse: tokens => tokens.map(token => {
|
|
193
|
+
const nodePoints = api.getNodePoints();
|
|
194
|
+
let startIndex = token.startIndex + token.thickness;
|
|
195
|
+
let endIndex = token.endIndex - token.thickness;
|
|
196
|
+
let isAllSpace = true;
|
|
197
|
+
for (let i = startIndex; i < endIndex; ++i) {
|
|
198
|
+
if (character.isSpaceLike(nodePoints[i].codePoint))
|
|
199
|
+
continue;
|
|
200
|
+
isAllSpace = false;
|
|
201
|
+
break;
|
|
202
|
+
}
|
|
203
|
+
if (!isAllSpace && startIndex + 2 < endIndex) {
|
|
204
|
+
const firstCharacter = nodePoints[startIndex].codePoint;
|
|
205
|
+
const lastCharacter = nodePoints[endIndex - 1].codePoint;
|
|
206
|
+
if (character.isSpaceLike(firstCharacter) && character.isSpaceLike(lastCharacter)) {
|
|
207
|
+
startIndex += 1;
|
|
208
|
+
endIndex -= 1;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
const value = character.calcStringFromNodePoints(nodePoints, startIndex, endIndex).replace(/\n/g, ' ');
|
|
212
|
+
const node = api.shouldReservePosition
|
|
213
|
+
? { type: ast.InlineMathType, position: api.calcPosition(token), value }
|
|
214
|
+
: { type: ast.InlineMathType, value };
|
|
215
|
+
return node;
|
|
216
|
+
}),
|
|
217
|
+
};
|
|
218
|
+
};
|
|
219
|
+
|
|
219
220
|
const uniqueName = '@yozora/tokenizer-inline-math';
|
|
220
221
|
const uniqueName_withBacktick = '@yozora/tokenizer-inline-math_with_backtick';
|
|
221
222
|
|
|
@@ -238,4 +239,5 @@ exports.InlineMathTokenizerName = uniqueName;
|
|
|
238
239
|
exports.InlineMathTokenizerName_withBacktick = uniqueName_withBacktick;
|
|
239
240
|
exports.default = InlineMathTokenizer;
|
|
240
241
|
exports.inlineMathMatch = match;
|
|
242
|
+
exports.inlineMathMatchWithBacktick = matchWithBacktick;
|
|
241
243
|
exports.inlineMathParse = parse;
|
package/lib/esm/index.mjs
CHANGED
|
@@ -23,8 +23,9 @@ const match = function (api) {
|
|
|
23
23
|
const leftCodePoint = i === blockStartIndex ? null : nodePoints[i - 1].codePoint;
|
|
24
24
|
i = eatOptionalCharacters(nodePoints, i + 1, blockEndIndex, AsciiCodePoint.DOLLAR_SIGN);
|
|
25
25
|
const rightCodePoint = i === blockEndIndex ? null : nodePoints[i].codePoint;
|
|
26
|
-
const
|
|
27
|
-
const
|
|
26
|
+
const thickness = i - _startIndex;
|
|
27
|
+
const isPotentialOpener = thickness > 1 || checkIfPotentialOpener(leftCodePoint, rightCodePoint);
|
|
28
|
+
const isPotentialCloser = thickness > 1 || checkIfPotentialCloser(leftCodePoint, rightCodePoint);
|
|
28
29
|
if (!isPotentialOpener && !isPotentialCloser)
|
|
29
30
|
break;
|
|
30
31
|
const delimiterType = isPotentialOpener
|
|
@@ -36,7 +37,7 @@ const match = function (api) {
|
|
|
36
37
|
type: delimiterType,
|
|
37
38
|
startIndex: _startIndex,
|
|
38
39
|
endIndex: i,
|
|
39
|
-
thickness
|
|
40
|
+
thickness,
|
|
40
41
|
};
|
|
41
42
|
return delimiter;
|
|
42
43
|
}
|
|
@@ -81,36 +82,6 @@ function processDelimiterPair(openerDelimiter, closerDelimiter) {
|
|
|
81
82
|
return { tokens: [token] };
|
|
82
83
|
}
|
|
83
84
|
|
|
84
|
-
const parse = function (api) {
|
|
85
|
-
return {
|
|
86
|
-
parse: tokens => tokens.map(token => {
|
|
87
|
-
const nodePoints = api.getNodePoints();
|
|
88
|
-
let startIndex = token.startIndex + token.thickness;
|
|
89
|
-
let endIndex = token.endIndex - token.thickness;
|
|
90
|
-
let isAllSpace = true;
|
|
91
|
-
for (let i = startIndex; i < endIndex; ++i) {
|
|
92
|
-
if (isSpaceLike(nodePoints[i].codePoint))
|
|
93
|
-
continue;
|
|
94
|
-
isAllSpace = false;
|
|
95
|
-
break;
|
|
96
|
-
}
|
|
97
|
-
if (!isAllSpace && startIndex + 2 < endIndex) {
|
|
98
|
-
const firstCharacter = nodePoints[startIndex].codePoint;
|
|
99
|
-
const lastCharacter = nodePoints[endIndex - 1].codePoint;
|
|
100
|
-
if (isSpaceLike(firstCharacter) && isSpaceLike(lastCharacter)) {
|
|
101
|
-
startIndex += 1;
|
|
102
|
-
endIndex -= 1;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
const value = calcStringFromNodePoints(nodePoints, startIndex, endIndex).replace(/\n/g, ' ');
|
|
106
|
-
const node = api.shouldReservePosition
|
|
107
|
-
? { type: InlineMathType, position: api.calcPosition(token), value }
|
|
108
|
-
: { type: InlineMathType, value };
|
|
109
|
-
return node;
|
|
110
|
-
}),
|
|
111
|
-
};
|
|
112
|
-
};
|
|
113
|
-
|
|
114
85
|
const matchWithBacktick = function (api) {
|
|
115
86
|
return { findDelimiter, processSingleDelimiter };
|
|
116
87
|
function* findDelimiter() {
|
|
@@ -212,6 +183,36 @@ const matchWithBacktick = function (api) {
|
|
|
212
183
|
}
|
|
213
184
|
};
|
|
214
185
|
|
|
186
|
+
const parse = function (api) {
|
|
187
|
+
return {
|
|
188
|
+
parse: tokens => tokens.map(token => {
|
|
189
|
+
const nodePoints = api.getNodePoints();
|
|
190
|
+
let startIndex = token.startIndex + token.thickness;
|
|
191
|
+
let endIndex = token.endIndex - token.thickness;
|
|
192
|
+
let isAllSpace = true;
|
|
193
|
+
for (let i = startIndex; i < endIndex; ++i) {
|
|
194
|
+
if (isSpaceLike(nodePoints[i].codePoint))
|
|
195
|
+
continue;
|
|
196
|
+
isAllSpace = false;
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
if (!isAllSpace && startIndex + 2 < endIndex) {
|
|
200
|
+
const firstCharacter = nodePoints[startIndex].codePoint;
|
|
201
|
+
const lastCharacter = nodePoints[endIndex - 1].codePoint;
|
|
202
|
+
if (isSpaceLike(firstCharacter) && isSpaceLike(lastCharacter)) {
|
|
203
|
+
startIndex += 1;
|
|
204
|
+
endIndex -= 1;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
const value = calcStringFromNodePoints(nodePoints, startIndex, endIndex).replace(/\n/g, ' ');
|
|
208
|
+
const node = api.shouldReservePosition
|
|
209
|
+
? { type: InlineMathType, position: api.calcPosition(token), value }
|
|
210
|
+
: { type: InlineMathType, value };
|
|
211
|
+
return node;
|
|
212
|
+
}),
|
|
213
|
+
};
|
|
214
|
+
};
|
|
215
|
+
|
|
215
216
|
const uniqueName = '@yozora/tokenizer-inline-math';
|
|
216
217
|
const uniqueName_withBacktick = '@yozora/tokenizer-inline-math_with_backtick';
|
|
217
218
|
|
|
@@ -229,4 +230,4 @@ class InlineMathTokenizer extends BaseInlineTokenizer {
|
|
|
229
230
|
}
|
|
230
231
|
}
|
|
231
232
|
|
|
232
|
-
export { InlineMathTokenizer, uniqueName as InlineMathTokenizerName, uniqueName_withBacktick as InlineMathTokenizerName_withBacktick, InlineMathTokenizer as default, match as inlineMathMatch, parse as inlineMathParse };
|
|
233
|
+
export { InlineMathTokenizer, uniqueName as InlineMathTokenizerName, uniqueName_withBacktick as InlineMathTokenizerName_withBacktick, InlineMathTokenizer as default, match as inlineMathMatch, matchWithBacktick as inlineMathMatchWithBacktick, parse as inlineMathParse };
|
package/lib/types/index.d.ts
CHANGED
|
@@ -32,6 +32,8 @@ interface ITokenizerProps extends Partial<IBaseInlineTokenizerProps> {
|
|
|
32
32
|
|
|
33
33
|
declare const match: IMatchInlineHookCreator<T, IDelimiter, IToken, IThis>;
|
|
34
34
|
|
|
35
|
+
declare const matchWithBacktick: IMatchInlineHookCreator<T, IDelimiter, IToken, IThis>;
|
|
36
|
+
|
|
35
37
|
declare const parse: IParseInlineHookCreator<T, IToken, INode, IThis>;
|
|
36
38
|
|
|
37
39
|
/**
|
|
@@ -43,4 +45,4 @@ declare class InlineMathTokenizer extends BaseInlineTokenizer<T, IDelimiter, ITo
|
|
|
43
45
|
constructor(props?: ITokenizerProps);
|
|
44
46
|
}
|
|
45
47
|
|
|
46
|
-
export { type IThis as IInlineMathHookContext, type IToken as IInlineMathToken, type ITokenizerProps as IInlineMathTokenizerProps, InlineMathTokenizer, uniqueName as InlineMathTokenizerName, uniqueName_withBacktick as InlineMathTokenizerName_withBacktick, InlineMathTokenizer as default, match as inlineMathMatch, parse as inlineMathParse };
|
|
48
|
+
export { type IThis as IInlineMathHookContext, type IToken as IInlineMathToken, type ITokenizerProps as IInlineMathTokenizerProps, InlineMathTokenizer, uniqueName as InlineMathTokenizerName, uniqueName_withBacktick as InlineMathTokenizerName_withBacktick, InlineMathTokenizer as default, match as inlineMathMatch, matchWithBacktick as inlineMathMatchWithBacktick, parse as inlineMathParse };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yozora/tokenizer-inline-math",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.11",
|
|
4
4
|
"description": "Tokenizer for processing inline math (formulas)",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "guanghechen",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"url": "https://github.com/yozorajs/yozora.git",
|
|
12
12
|
"directory": "tokenizers/inline-math"
|
|
13
13
|
},
|
|
14
|
-
"homepage": "https://github.com/yozorajs/yozora/tree/v2.3.
|
|
14
|
+
"homepage": "https://github.com/yozorajs/yozora/tree/v2.3.10/tokenizers/inline-math",
|
|
15
15
|
"keywords": [
|
|
16
16
|
"yozora",
|
|
17
17
|
"markdown",
|
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
"README.md"
|
|
45
45
|
],
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@yozora/ast": "^2.3.
|
|
48
|
-
"@yozora/character": "^2.3.
|
|
49
|
-
"@yozora/core-tokenizer": "^2.3.
|
|
47
|
+
"@yozora/ast": "^2.3.11",
|
|
48
|
+
"@yozora/character": "^2.3.11",
|
|
49
|
+
"@yozora/core-tokenizer": "^2.3.11"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "dcc0a95d27fcdac98153e0facd658dcce104a455"
|
|
52
52
|
}
|