@yozora/tokenizer-image-reference 1.3.0 → 2.0.0-alpha.3
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/README.md +4 -6
- package/lib/cjs/index.js +55 -30
- package/lib/esm/index.js +54 -31
- package/lib/types/index.d.ts +4 -4
- package/lib/types/match.d.ts +33 -0
- package/lib/types/parse.d.ts +3 -0
- package/lib/types/tokenizer.d.ts +6 -52
- package/lib/types/types.d.ts +9 -8
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -84,14 +84,14 @@ so you can use `YozoraParser` / `GfmExParser` / `GfmParser` directly.
|
|
|
84
84
|
registered in *YastParser* as a plugin-in before it can be used.
|
|
85
85
|
|
|
86
86
|
```typescript {4,9}
|
|
87
|
-
import {
|
|
87
|
+
import { DefaultParser } from '@yozora/core-parser'
|
|
88
88
|
import ParagraphTokenizer from '@yozora/tokenizer-paragraph'
|
|
89
89
|
import TextTokenizer from '@yozora/tokenizer-text'
|
|
90
90
|
import ImageReferenceTokenizer from '@yozora/tokenizer-image-reference'
|
|
91
91
|
|
|
92
|
-
const parser = new
|
|
93
|
-
.
|
|
94
|
-
.
|
|
92
|
+
const parser = new DefaultParser()
|
|
93
|
+
.useFallbackTokenizer(new ParagraphTokenizer())
|
|
94
|
+
.useFallbackTokenizer(new TextTokenizer())
|
|
95
95
|
.useTokenizer(new ImageReferenceTokenizer())
|
|
96
96
|
|
|
97
97
|
// parse source markdown content
|
|
@@ -231,7 +231,6 @@ Name | Type | Required | Default
|
|
|
231
231
|
[@yozora/tokenizer-link]: https://github.com/yozorajs/yozora/tree/main/tokenizers/link#readme
|
|
232
232
|
[@yozora/tokenizer-link-reference]: https://github.com/yozorajs/yozora/tree/main/tokenizers/link-reference#readme
|
|
233
233
|
[@yozora/tokenizer-list]: https://github.com/yozorajs/yozora/tree/main/tokenizers/list#readme
|
|
234
|
-
[@yozora/tokenizer-list-item]: https://github.com/yozorajs/yozora/tree/main/tokenizers/list-item#readme
|
|
235
234
|
[@yozora/tokenizer-math]: https://github.com/yozorajs/yozora/tree/main/tokenizers/math#readme
|
|
236
235
|
[@yozora/tokenizer-paragraph]: https://github.com/yozorajs/yozora/tree/main/tokenizers/paragraph#readme
|
|
237
236
|
[@yozora/tokenizer-setext-heading]: https://github.com/yozorajs/yozora/tree/main/tokenizers/setext-heading#readme
|
|
@@ -291,7 +290,6 @@ Name | Type | Required | Default
|
|
|
291
290
|
[doc-@yozora/tokenizer-definition]: https://yozora.guanghechen.com/docs/package/tokenizer-definition
|
|
292
291
|
[doc-@yozora/tokenizer-link-reference]: https://yozora.guanghechen.com/docs/package/tokenizer-link-reference
|
|
293
292
|
[doc-@yozora/tokenizer-list]: https://yozora.guanghechen.com/docs/package/tokenizer-list
|
|
294
|
-
[doc-@yozora/tokenizer-list-item]: https://yozora.guanghechen.com/docs/package/tokenizer-list-item
|
|
295
293
|
[doc-@yozora/tokenizer-math]: https://yozora.guanghechen.com/docs/package/tokenizer-math
|
|
296
294
|
[doc-@yozora/tokenizer-paragraph]: https://yozora.guanghechen.com/docs/package/tokenizer-paragraph
|
|
297
295
|
[doc-@yozora/tokenizer-setext-heading]: https://yozora.guanghechen.com/docs/package/tokenizer-setext-heading
|
package/lib/cjs/index.js
CHANGED
|
@@ -5,20 +5,16 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var ast = require('@yozora/ast');
|
|
6
6
|
var character = require('@yozora/character');
|
|
7
7
|
var coreTokenizer = require('@yozora/core-tokenizer');
|
|
8
|
-
var tokenizerImage = require('@yozora/tokenizer-image');
|
|
9
8
|
var tokenizerLink = require('@yozora/tokenizer-link');
|
|
9
|
+
var tokenizerImage = require('@yozora/tokenizer-image');
|
|
10
10
|
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
priority: (_b = props.priority) !== null && _b !== void 0 ? _b : coreTokenizer.TokenizerPriority.LINKS,
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
_findDelimiter(startIndex, endIndex, api) {
|
|
11
|
+
const match = function (api) {
|
|
12
|
+
return {
|
|
13
|
+
findDelimiter: () => coreTokenizer.genFindDelimiter(_findDelimiter),
|
|
14
|
+
isDelimiterPair,
|
|
15
|
+
processDelimiterPair,
|
|
16
|
+
};
|
|
17
|
+
function _findDelimiter(startIndex, endIndex) {
|
|
22
18
|
const nodePoints = api.getNodePoints();
|
|
23
19
|
for (let i = startIndex; i < endIndex; ++i) {
|
|
24
20
|
const c = nodePoints[i].codePoint;
|
|
@@ -27,8 +23,7 @@ class ImageReferenceTokenizer extends coreTokenizer.BaseInlineTokenizer {
|
|
|
27
23
|
i += 1;
|
|
28
24
|
break;
|
|
29
25
|
case character.AsciiCodePoint.EXCLAMATION_MARK: {
|
|
30
|
-
if (i + 1 >= endIndex ||
|
|
31
|
-
nodePoints[i + 1].codePoint !== character.AsciiCodePoint.OPEN_BRACKET) {
|
|
26
|
+
if (i + 1 >= endIndex || nodePoints[i + 1].codePoint !== character.AsciiCodePoint.OPEN_BRACKET) {
|
|
32
27
|
break;
|
|
33
28
|
}
|
|
34
29
|
return {
|
|
@@ -45,8 +40,7 @@ class ImageReferenceTokenizer extends coreTokenizer.BaseInlineTokenizer {
|
|
|
45
40
|
endIndex: i + 1,
|
|
46
41
|
brackets: [],
|
|
47
42
|
};
|
|
48
|
-
if (i + 1 >= endIndex ||
|
|
49
|
-
nodePoints[i + 1].codePoint !== character.AsciiCodePoint.OPEN_BRACKET) {
|
|
43
|
+
if (i + 1 >= endIndex || nodePoints[i + 1].codePoint !== character.AsciiCodePoint.OPEN_BRACKET) {
|
|
50
44
|
return delimiter;
|
|
51
45
|
}
|
|
52
46
|
const result = coreTokenizer.eatLinkLabel(nodePoints, i + 1, endIndex);
|
|
@@ -83,7 +77,7 @@ class ImageReferenceTokenizer extends coreTokenizer.BaseInlineTokenizer {
|
|
|
83
77
|
}
|
|
84
78
|
return null;
|
|
85
79
|
}
|
|
86
|
-
isDelimiterPair(openerDelimiter, closerDelimiter, internalTokens
|
|
80
|
+
function isDelimiterPair(openerDelimiter, closerDelimiter, internalTokens) {
|
|
87
81
|
const nodePoints = api.getNodePoints();
|
|
88
82
|
const balancedBracketsStatus = tokenizerLink.checkBalancedBracketsStatus(openerDelimiter.endIndex, closerDelimiter.startIndex, internalTokens, nodePoints);
|
|
89
83
|
switch (balancedBracketsStatus) {
|
|
@@ -95,7 +89,7 @@ class ImageReferenceTokenizer extends coreTokenizer.BaseInlineTokenizer {
|
|
|
95
89
|
return { paired: false, opener: true, closer: false };
|
|
96
90
|
}
|
|
97
91
|
}
|
|
98
|
-
processDelimiterPair(openerDelimiter, closerDelimiter, internalTokens
|
|
92
|
+
function processDelimiterPair(openerDelimiter, closerDelimiter, internalTokens) {
|
|
99
93
|
const nodePoints = api.getNodePoints();
|
|
100
94
|
const bracket = closerDelimiter.brackets[0];
|
|
101
95
|
if (bracket != null && bracket.identifier != null) {
|
|
@@ -130,20 +124,51 @@ class ImageReferenceTokenizer extends coreTokenizer.BaseInlineTokenizer {
|
|
|
130
124
|
}
|
|
131
125
|
return { tokens: internalTokens };
|
|
132
126
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
identifier,
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
const parse = function (api) {
|
|
130
|
+
return {
|
|
131
|
+
parse: tokens => tokens.map(token => {
|
|
132
|
+
const { identifier, label, referenceType } = token;
|
|
133
|
+
const children = api.parseInlineTokens(token.children);
|
|
134
|
+
const alt = tokenizerImage.calcImageAlt(children);
|
|
135
|
+
const node = api.shouldReservePosition
|
|
136
|
+
? {
|
|
137
|
+
type: ast.ImageReferenceType,
|
|
138
|
+
position: api.calcPosition(token),
|
|
139
|
+
identifier,
|
|
140
|
+
label,
|
|
141
|
+
referenceType,
|
|
142
|
+
alt,
|
|
143
|
+
}
|
|
144
|
+
: {
|
|
145
|
+
type: ast.ImageReferenceType,
|
|
146
|
+
identifier,
|
|
147
|
+
label,
|
|
148
|
+
referenceType,
|
|
149
|
+
alt,
|
|
150
|
+
};
|
|
151
|
+
return node;
|
|
152
|
+
}),
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
const uniqueName = '@yozora/tokenizer-image-reference';
|
|
157
|
+
|
|
158
|
+
class ImageReferenceTokenizer extends coreTokenizer.BaseInlineTokenizer {
|
|
159
|
+
constructor(props = {}) {
|
|
160
|
+
var _a, _b;
|
|
161
|
+
super({
|
|
162
|
+
name: (_a = props.name) !== null && _a !== void 0 ? _a : uniqueName,
|
|
163
|
+
priority: (_b = props.priority) !== null && _b !== void 0 ? _b : coreTokenizer.TokenizerPriority.LINKS,
|
|
164
|
+
});
|
|
165
|
+
this.match = match;
|
|
166
|
+
this.parse = parse;
|
|
144
167
|
}
|
|
145
168
|
}
|
|
146
169
|
|
|
147
170
|
exports.ImageReferenceTokenizer = ImageReferenceTokenizer;
|
|
148
171
|
exports.ImageReferenceTokenizerName = uniqueName;
|
|
149
|
-
exports[
|
|
172
|
+
exports["default"] = ImageReferenceTokenizer;
|
|
173
|
+
exports.imageReferenceMatch = match;
|
|
174
|
+
exports.imageReferenceParse = parse;
|
package/lib/esm/index.js
CHANGED
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
import { ImageReferenceType } from '@yozora/ast';
|
|
2
2
|
import { AsciiCodePoint } from '@yozora/character';
|
|
3
|
-
import { BaseInlineTokenizer, TokenizerPriority
|
|
4
|
-
import { calcImageAlt } from '@yozora/tokenizer-image';
|
|
3
|
+
import { genFindDelimiter, eatLinkLabel, BaseInlineTokenizer, TokenizerPriority } from '@yozora/core-tokenizer';
|
|
5
4
|
import { checkBalancedBracketsStatus } from '@yozora/tokenizer-link';
|
|
5
|
+
import { calcImageAlt } from '@yozora/tokenizer-image';
|
|
6
6
|
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
priority: (_b = props.priority) !== null && _b !== void 0 ? _b : TokenizerPriority.LINKS,
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
_findDelimiter(startIndex, endIndex, api) {
|
|
7
|
+
const match = function (api) {
|
|
8
|
+
return {
|
|
9
|
+
findDelimiter: () => genFindDelimiter(_findDelimiter),
|
|
10
|
+
isDelimiterPair,
|
|
11
|
+
processDelimiterPair,
|
|
12
|
+
};
|
|
13
|
+
function _findDelimiter(startIndex, endIndex) {
|
|
18
14
|
const nodePoints = api.getNodePoints();
|
|
19
15
|
for (let i = startIndex; i < endIndex; ++i) {
|
|
20
16
|
const c = nodePoints[i].codePoint;
|
|
@@ -23,8 +19,7 @@ class ImageReferenceTokenizer extends BaseInlineTokenizer {
|
|
|
23
19
|
i += 1;
|
|
24
20
|
break;
|
|
25
21
|
case AsciiCodePoint.EXCLAMATION_MARK: {
|
|
26
|
-
if (i + 1 >= endIndex ||
|
|
27
|
-
nodePoints[i + 1].codePoint !== AsciiCodePoint.OPEN_BRACKET) {
|
|
22
|
+
if (i + 1 >= endIndex || nodePoints[i + 1].codePoint !== AsciiCodePoint.OPEN_BRACKET) {
|
|
28
23
|
break;
|
|
29
24
|
}
|
|
30
25
|
return {
|
|
@@ -41,8 +36,7 @@ class ImageReferenceTokenizer extends BaseInlineTokenizer {
|
|
|
41
36
|
endIndex: i + 1,
|
|
42
37
|
brackets: [],
|
|
43
38
|
};
|
|
44
|
-
if (i + 1 >= endIndex ||
|
|
45
|
-
nodePoints[i + 1].codePoint !== AsciiCodePoint.OPEN_BRACKET) {
|
|
39
|
+
if (i + 1 >= endIndex || nodePoints[i + 1].codePoint !== AsciiCodePoint.OPEN_BRACKET) {
|
|
46
40
|
return delimiter;
|
|
47
41
|
}
|
|
48
42
|
const result = eatLinkLabel(nodePoints, i + 1, endIndex);
|
|
@@ -79,7 +73,7 @@ class ImageReferenceTokenizer extends BaseInlineTokenizer {
|
|
|
79
73
|
}
|
|
80
74
|
return null;
|
|
81
75
|
}
|
|
82
|
-
isDelimiterPair(openerDelimiter, closerDelimiter, internalTokens
|
|
76
|
+
function isDelimiterPair(openerDelimiter, closerDelimiter, internalTokens) {
|
|
83
77
|
const nodePoints = api.getNodePoints();
|
|
84
78
|
const balancedBracketsStatus = checkBalancedBracketsStatus(openerDelimiter.endIndex, closerDelimiter.startIndex, internalTokens, nodePoints);
|
|
85
79
|
switch (balancedBracketsStatus) {
|
|
@@ -91,7 +85,7 @@ class ImageReferenceTokenizer extends BaseInlineTokenizer {
|
|
|
91
85
|
return { paired: false, opener: true, closer: false };
|
|
92
86
|
}
|
|
93
87
|
}
|
|
94
|
-
processDelimiterPair(openerDelimiter, closerDelimiter, internalTokens
|
|
88
|
+
function processDelimiterPair(openerDelimiter, closerDelimiter, internalTokens) {
|
|
95
89
|
const nodePoints = api.getNodePoints();
|
|
96
90
|
const bracket = closerDelimiter.brackets[0];
|
|
97
91
|
if (bracket != null && bracket.identifier != null) {
|
|
@@ -126,18 +120,47 @@ class ImageReferenceTokenizer extends BaseInlineTokenizer {
|
|
|
126
120
|
}
|
|
127
121
|
return { tokens: internalTokens };
|
|
128
122
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
identifier,
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
const parse = function (api) {
|
|
126
|
+
return {
|
|
127
|
+
parse: tokens => tokens.map(token => {
|
|
128
|
+
const { identifier, label, referenceType } = token;
|
|
129
|
+
const children = api.parseInlineTokens(token.children);
|
|
130
|
+
const alt = calcImageAlt(children);
|
|
131
|
+
const node = api.shouldReservePosition
|
|
132
|
+
? {
|
|
133
|
+
type: ImageReferenceType,
|
|
134
|
+
position: api.calcPosition(token),
|
|
135
|
+
identifier,
|
|
136
|
+
label,
|
|
137
|
+
referenceType,
|
|
138
|
+
alt,
|
|
139
|
+
}
|
|
140
|
+
: {
|
|
141
|
+
type: ImageReferenceType,
|
|
142
|
+
identifier,
|
|
143
|
+
label,
|
|
144
|
+
referenceType,
|
|
145
|
+
alt,
|
|
146
|
+
};
|
|
147
|
+
return node;
|
|
148
|
+
}),
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
const uniqueName = '@yozora/tokenizer-image-reference';
|
|
153
|
+
|
|
154
|
+
class ImageReferenceTokenizer extends BaseInlineTokenizer {
|
|
155
|
+
constructor(props = {}) {
|
|
156
|
+
var _a, _b;
|
|
157
|
+
super({
|
|
158
|
+
name: (_a = props.name) !== null && _a !== void 0 ? _a : uniqueName,
|
|
159
|
+
priority: (_b = props.priority) !== null && _b !== void 0 ? _b : TokenizerPriority.LINKS,
|
|
160
|
+
});
|
|
161
|
+
this.match = match;
|
|
162
|
+
this.parse = parse;
|
|
140
163
|
}
|
|
141
164
|
}
|
|
142
165
|
|
|
143
|
-
export { ImageReferenceTokenizer, uniqueName as ImageReferenceTokenizerName, ImageReferenceTokenizer as default };
|
|
166
|
+
export { ImageReferenceTokenizer, uniqueName as ImageReferenceTokenizerName, ImageReferenceTokenizer as default, match as imageReferenceMatch, parse as imageReferenceParse };
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
1
|
+
export { match as imageReferenceMatch } from './match';
|
|
2
|
+
export { parse as imageReferenceParse } from './parse';
|
|
3
|
+
export { ImageReferenceTokenizer, ImageReferenceTokenizer as default } from './tokenizer';
|
|
3
4
|
export { uniqueName as ImageReferenceTokenizerName } from './types';
|
|
4
|
-
export type {
|
|
5
|
-
export default ImageReferenceTokenizer;
|
|
5
|
+
export type { IThis as IImageReferenceHookContext, IToken as IImageReferenceToken, ITokenizerProps as IImageReferenceTokenizerProps, } from './types';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { IMatchInlineHookCreator } from '@yozora/core-tokenizer';
|
|
2
|
+
import type { IDelimiter, IThis, IToken, T } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Syntax for image-references is like the syntax for link-references, with one
|
|
5
|
+
* difference. Instead of link text, we have an image description. The rules for
|
|
6
|
+
* this are the same as for link text, except that
|
|
7
|
+
*
|
|
8
|
+
* a) an image description starts with '![' rather than '[', and
|
|
9
|
+
* b) an image description may contain links.
|
|
10
|
+
*
|
|
11
|
+
* An image description has inline elements as its contents. When an image is
|
|
12
|
+
* rendered to HTML, this is standardly used as the image’s alt attribute.
|
|
13
|
+
*
|
|
14
|
+
* One type of opener delimiter: '!['
|
|
15
|
+
*
|
|
16
|
+
* Three types of closer delimiter: ']', '][]' something like '][bar]'
|
|
17
|
+
*
|
|
18
|
+
* ------
|
|
19
|
+
*
|
|
20
|
+
* A 'opener' type delimiter is one of the following forms:
|
|
21
|
+
*
|
|
22
|
+
* - '!['
|
|
23
|
+
*
|
|
24
|
+
* A 'closer' type delimiter is one of the following forms:
|
|
25
|
+
*
|
|
26
|
+
* - ']'
|
|
27
|
+
* - '][]'
|
|
28
|
+
* - '][identifier]'
|
|
29
|
+
*
|
|
30
|
+
* @see https://github.com/syntax-tree/mdast#imagereference
|
|
31
|
+
* @see https://github.github.com/gfm/#images
|
|
32
|
+
*/
|
|
33
|
+
export declare const match: IMatchInlineHookCreator<T, IDelimiter, IToken, IThis>;
|
package/lib/types/tokenizer.d.ts
CHANGED
|
@@ -1,59 +1,13 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { MatchInlinePhaseApi, ResultOfIsDelimiterPair, ResultOfProcessDelimiterPair, Tokenizer, TokenizerMatchInlineHook, TokenizerParseInlineHook, YastInlineToken } from '@yozora/core-tokenizer';
|
|
1
|
+
import type { IInlineTokenizer, IMatchInlineHookCreator, IParseInlineHookCreator } from '@yozora/core-tokenizer';
|
|
3
2
|
import { BaseInlineTokenizer } from '@yozora/core-tokenizer';
|
|
4
|
-
import type {
|
|
3
|
+
import type { IDelimiter, INode, IThis, IToken, ITokenizerProps, T } from './types';
|
|
5
4
|
/**
|
|
6
5
|
* Lexical Analyzer for ImageReference.
|
|
7
|
-
*
|
|
8
|
-
* Syntax for image-references is like the syntax for link-references, with one
|
|
9
|
-
* difference. Instead of link text, we have an image description. The rules for
|
|
10
|
-
* this are the same as for link text, except that
|
|
11
|
-
*
|
|
12
|
-
* a) an image description starts with '![' rather than '[', and
|
|
13
|
-
* b) an image description may contain links.
|
|
14
|
-
*
|
|
15
|
-
* An image description has inline elements as its contents. When an image is
|
|
16
|
-
* rendered to HTML, this is standardly used as the image’s alt attribute.
|
|
17
|
-
*
|
|
18
|
-
* One type of opener delimiter: '!['
|
|
19
|
-
*
|
|
20
|
-
* Three types of closer delimiter: ']', '][]' something like '][bar]'
|
|
21
|
-
*
|
|
22
|
-
* ------
|
|
23
|
-
*
|
|
24
|
-
* A 'opener' type delimiter is one of the following forms:
|
|
25
|
-
*
|
|
26
|
-
* - '!['
|
|
27
|
-
*
|
|
28
|
-
* A 'closer' type delimiter is one of the following forms:
|
|
29
|
-
*
|
|
30
|
-
* - ']'
|
|
31
|
-
* - '][]'
|
|
32
|
-
* - '][identifier]'
|
|
33
|
-
*
|
|
34
6
|
* @see https://github.com/syntax-tree/mdast#imagereference
|
|
35
7
|
* @see https://github.github.com/gfm/#images
|
|
36
8
|
*/
|
|
37
|
-
export declare class ImageReferenceTokenizer extends BaseInlineTokenizer<
|
|
38
|
-
constructor(props?:
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
* @see BaseInlineTokenizer
|
|
42
|
-
*/
|
|
43
|
-
protected _findDelimiter(startIndex: number, endIndex: number, api: Readonly<MatchInlinePhaseApi>): Delimiter | null;
|
|
44
|
-
/**
|
|
45
|
-
* @override
|
|
46
|
-
* @see TokenizerMatchInlineHook
|
|
47
|
-
*/
|
|
48
|
-
isDelimiterPair(openerDelimiter: Delimiter, closerDelimiter: Delimiter, internalTokens: ReadonlyArray<YastInlineToken>, api: Readonly<MatchInlinePhaseApi>): ResultOfIsDelimiterPair;
|
|
49
|
-
/**
|
|
50
|
-
* @override
|
|
51
|
-
* @see TokenizerMatchInlineHook
|
|
52
|
-
*/
|
|
53
|
-
processDelimiterPair(openerDelimiter: Delimiter, closerDelimiter: Delimiter, internalTokens: ReadonlyArray<YastInlineToken>, api: Readonly<MatchInlinePhaseApi>): ResultOfProcessDelimiterPair<T, Token, Delimiter>;
|
|
54
|
-
/**
|
|
55
|
-
* @override
|
|
56
|
-
* @see TokenizerParseInlineHook
|
|
57
|
-
*/
|
|
58
|
-
parseInline(token: Token, children: YastNode[]): Node;
|
|
9
|
+
export declare class ImageReferenceTokenizer extends BaseInlineTokenizer<T, IDelimiter, IToken, INode, IThis> implements IInlineTokenizer<T, IDelimiter, IToken, INode, IThis> {
|
|
10
|
+
constructor(props?: ITokenizerProps);
|
|
11
|
+
readonly match: IMatchInlineHookCreator<T, IDelimiter, IToken, IThis>;
|
|
12
|
+
readonly parse: IParseInlineHookCreator<T, IToken, INode, IThis>;
|
|
59
13
|
}
|
package/lib/types/types.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import type { ImageReference, ImageReferenceType,
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
1
|
+
import type { Association, ImageReference, ImageReferenceType, Reference } from '@yozora/ast';
|
|
2
|
+
import type { IBaseInlineTokenizerProps, IPartialYastInlineToken, ITokenizer, IYastTokenDelimiter } from '@yozora/core-tokenizer';
|
|
3
|
+
import type { ILinkReferenceDelimiterBracket } from '@yozora/tokenizer-link-reference';
|
|
4
4
|
export declare const uniqueName = "@yozora/tokenizer-image-reference";
|
|
5
5
|
export declare type T = ImageReferenceType;
|
|
6
|
-
export declare type
|
|
7
|
-
export interface
|
|
6
|
+
export declare type INode = ImageReference;
|
|
7
|
+
export interface IToken extends IPartialYastInlineToken<T>, Association, Reference {
|
|
8
8
|
}
|
|
9
|
-
export interface
|
|
10
|
-
brackets:
|
|
9
|
+
export interface IDelimiter extends IYastTokenDelimiter {
|
|
10
|
+
brackets: ILinkReferenceDelimiterBracket[];
|
|
11
11
|
}
|
|
12
|
-
export declare type
|
|
12
|
+
export declare type IThis = ITokenizer;
|
|
13
|
+
export declare type ITokenizerProps = Partial<IBaseInlineTokenizerProps>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yozora/tokenizer-image-reference",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-alpha.3",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "guanghechen",
|
|
6
6
|
"url": "https://github.com/guanghechen/"
|
|
@@ -35,11 +35,11 @@
|
|
|
35
35
|
"test": "cross-env TS_NODE_FILES=true jest --config ../../jest.config.js --rootDir ."
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@yozora/ast": "^
|
|
39
|
-
"@yozora/character": "^
|
|
40
|
-
"@yozora/core-tokenizer": "^
|
|
41
|
-
"@yozora/tokenizer-image": "^
|
|
42
|
-
"@yozora/tokenizer-link": "^
|
|
38
|
+
"@yozora/ast": "^2.0.0-alpha.3",
|
|
39
|
+
"@yozora/character": "^2.0.0-alpha.3",
|
|
40
|
+
"@yozora/core-tokenizer": "^2.0.0-alpha.3",
|
|
41
|
+
"@yozora/tokenizer-image": "^2.0.0-alpha.3",
|
|
42
|
+
"@yozora/tokenizer-link": "^2.0.0-alpha.3"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "9f274fc7487a8c1dd213405d92508f9a7621f730"
|
|
45
45
|
}
|