@yozora/tokenizer-image 1.2.1 → 2.0.0-alpha.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/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 { DefaultYastParser } from '@yozora/core-parser'
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 ImageTokenizer from '@yozora/tokenizer-image'
91
91
 
92
- const parser = new DefaultYastParser()
93
- .useBlockFallbackTokenizer(new ParagraphTokenizer())
94
- .useInlineFallbackTokenizer(new TextTokenizer())
92
+ const parser = new DefaultParser()
93
+ .useFallbackTokenizer(new ParagraphTokenizer())
94
+ .useFallbackTokenizer(new TextTokenizer())
95
95
  .useTokenizer(new ImageTokenizer())
96
96
 
97
97
  // parse source markdown content
@@ -223,7 +223,6 @@ Name | Type | Required | Default
223
223
  [@yozora/tokenizer-link]: https://github.com/yozorajs/yozora/tree/main/tokenizers/link#readme
224
224
  [@yozora/tokenizer-link-reference]: https://github.com/yozorajs/yozora/tree/main/tokenizers/link-reference#readme
225
225
  [@yozora/tokenizer-list]: https://github.com/yozorajs/yozora/tree/main/tokenizers/list#readme
226
- [@yozora/tokenizer-list-item]: https://github.com/yozorajs/yozora/tree/main/tokenizers/list-item#readme
227
226
  [@yozora/tokenizer-math]: https://github.com/yozorajs/yozora/tree/main/tokenizers/math#readme
228
227
  [@yozora/tokenizer-paragraph]: https://github.com/yozorajs/yozora/tree/main/tokenizers/paragraph#readme
229
228
  [@yozora/tokenizer-setext-heading]: https://github.com/yozorajs/yozora/tree/main/tokenizers/setext-heading#readme
@@ -283,7 +282,6 @@ Name | Type | Required | Default
283
282
  [doc-@yozora/tokenizer-definition]: https://yozora.guanghechen.com/docs/package/tokenizer-definition
284
283
  [doc-@yozora/tokenizer-link-reference]: https://yozora.guanghechen.com/docs/package/tokenizer-link-reference
285
284
  [doc-@yozora/tokenizer-list]: https://yozora.guanghechen.com/docs/package/tokenizer-list
286
- [doc-@yozora/tokenizer-list-item]: https://yozora.guanghechen.com/docs/package/tokenizer-list-item
287
285
  [doc-@yozora/tokenizer-math]: https://yozora.guanghechen.com/docs/package/tokenizer-math
288
286
  [doc-@yozora/tokenizer-paragraph]: https://yozora.guanghechen.com/docs/package/tokenizer-paragraph
289
287
  [doc-@yozora/tokenizer-setext-heading]: https://yozora.guanghechen.com/docs/package/tokenizer-setext-heading
package/lib/cjs/index.js CHANGED
@@ -7,8 +7,6 @@ var character = require('@yozora/character');
7
7
  var coreTokenizer = require('@yozora/core-tokenizer');
8
8
  var tokenizerLink = require('@yozora/tokenizer-link');
9
9
 
10
- const uniqueName = '@yozora/tokenizer-image';
11
-
12
10
  function calcImageAlt(nodes) {
13
11
  return nodes
14
12
  .map((o) => {
@@ -23,15 +21,14 @@ function calcImageAlt(nodes) {
23
21
  .join('');
24
22
  }
25
23
 
26
- class ImageTokenizer extends coreTokenizer.BaseInlineTokenizer {
27
- constructor(props = {}) {
28
- var _a, _b;
29
- super({
30
- name: (_a = props.name) !== null && _a !== void 0 ? _a : uniqueName,
31
- priority: (_b = props.priority) !== null && _b !== void 0 ? _b : coreTokenizer.TokenizerPriority.LINKS,
32
- });
33
- }
34
- _findDelimiter(startIndex, endIndex, nodePoints, api) {
24
+ const match = function (api) {
25
+ return {
26
+ findDelimiter: () => coreTokenizer.genFindDelimiter(_findDelimiter),
27
+ isDelimiterPair,
28
+ processDelimiterPair,
29
+ };
30
+ function _findDelimiter(startIndex, endIndex) {
31
+ const nodePoints = api.getNodePoints();
35
32
  const blockEndIndex = api.getBlockEndIndex();
36
33
  for (let i = startIndex; i < endIndex; ++i) {
37
34
  const c = nodePoints[i].codePoint;
@@ -40,8 +37,7 @@ class ImageTokenizer extends coreTokenizer.BaseInlineTokenizer {
40
37
  i += 1;
41
38
  break;
42
39
  case character.AsciiCodePoint.EXCLAMATION_MARK: {
43
- if (i + 1 < endIndex &&
44
- nodePoints[i + 1].codePoint === character.AsciiCodePoint.OPEN_BRACKET) {
40
+ if (i + 1 < endIndex && nodePoints[i + 1].codePoint === character.AsciiCodePoint.OPEN_BRACKET) {
45
41
  return {
46
42
  type: 'opener',
47
43
  startIndex: i,
@@ -66,8 +62,7 @@ class ImageTokenizer extends coreTokenizer.BaseInlineTokenizer {
66
62
  const _startIndex = i;
67
63
  const _endIndex = coreTokenizer.eatOptionalWhitespaces(nodePoints, titleEndIndex, blockEndIndex) + 1;
68
64
  if (_endIndex > blockEndIndex ||
69
- nodePoints[_endIndex - 1].codePoint !==
70
- character.AsciiCodePoint.CLOSE_PARENTHESIS) {
65
+ nodePoints[_endIndex - 1].codePoint !== character.AsciiCodePoint.CLOSE_PARENTHESIS) {
71
66
  break;
72
67
  }
73
68
  return {
@@ -89,7 +84,8 @@ class ImageTokenizer extends coreTokenizer.BaseInlineTokenizer {
89
84
  }
90
85
  return null;
91
86
  }
92
- isDelimiterPair(openerDelimiter, closerDelimiter, internalTokens, nodePoints) {
87
+ function isDelimiterPair(openerDelimiter, closerDelimiter, internalTokens) {
88
+ const nodePoints = api.getNodePoints();
93
89
  const balancedBracketsStatus = tokenizerLink.checkBalancedBracketsStatus(openerDelimiter.endIndex, closerDelimiter.startIndex, internalTokens, nodePoints);
94
90
  switch (balancedBracketsStatus) {
95
91
  case -1:
@@ -100,40 +96,62 @@ class ImageTokenizer extends coreTokenizer.BaseInlineTokenizer {
100
96
  return { paired: false, opener: true, closer: false };
101
97
  }
102
98
  }
103
- processDelimiterPair(openerDelimiter, closerDelimiter, internalTokens, nodePoints, api) {
99
+ function processDelimiterPair(openerDelimiter, closerDelimiter, internalTokens) {
104
100
  const token = {
105
101
  nodeType: ast.ImageType,
106
102
  startIndex: openerDelimiter.startIndex,
107
103
  endIndex: closerDelimiter.endIndex,
108
104
  destinationContent: closerDelimiter.destinationContent,
109
105
  titleContent: closerDelimiter.titleContent,
110
- children: api.resolveInternalTokens(internalTokens, openerDelimiter.endIndex, closerDelimiter.startIndex, nodePoints),
106
+ children: api.resolveInternalTokens(internalTokens, openerDelimiter.endIndex, closerDelimiter.startIndex),
111
107
  };
112
108
  return { tokens: [token] };
113
109
  }
114
- processToken(token, children, nodePoints) {
115
- let url = '';
116
- if (token.destinationContent != null) {
117
- let { startIndex, endIndex } = token.destinationContent;
118
- if (nodePoints[startIndex].codePoint === character.AsciiCodePoint.OPEN_ANGLE) {
119
- startIndex += 1;
120
- endIndex -= 1;
110
+ };
111
+
112
+ const parse = function (api) {
113
+ return {
114
+ parse: (token, children) => {
115
+ const nodePoints = api.getNodePoints();
116
+ let url = '';
117
+ if (token.destinationContent != null) {
118
+ let { startIndex, endIndex } = token.destinationContent;
119
+ if (nodePoints[startIndex].codePoint === character.AsciiCodePoint.OPEN_ANGLE) {
120
+ startIndex += 1;
121
+ endIndex -= 1;
122
+ }
123
+ const destination = character.calcEscapedStringFromNodePoints(nodePoints, startIndex, endIndex, true);
124
+ url = coreTokenizer.encodeLinkDestination(destination);
121
125
  }
122
- const destination = character.calcEscapedStringFromNodePoints(nodePoints, startIndex, endIndex, true);
123
- url = coreTokenizer.encodeLinkDestination(destination);
124
- }
125
- const alt = calcImageAlt(children || []);
126
- let title;
127
- if (token.titleContent != null) {
128
- const { startIndex, endIndex } = token.titleContent;
129
- title = character.calcEscapedStringFromNodePoints(nodePoints, startIndex + 1, endIndex - 1);
130
- }
131
- const result = { type: ast.ImageType, url, alt, title };
132
- return result;
126
+ const alt = calcImageAlt(children);
127
+ let title;
128
+ if (token.titleContent != null) {
129
+ const { startIndex, endIndex } = token.titleContent;
130
+ title = character.calcEscapedStringFromNodePoints(nodePoints, startIndex + 1, endIndex - 1);
131
+ }
132
+ const result = { type: ast.ImageType, url, alt, title };
133
+ return result;
134
+ },
135
+ };
136
+ };
137
+
138
+ const uniqueName = '@yozora/tokenizer-image';
139
+
140
+ class ImageTokenizer extends coreTokenizer.BaseInlineTokenizer {
141
+ constructor(props = {}) {
142
+ var _a, _b;
143
+ super({
144
+ name: (_a = props.name) !== null && _a !== void 0 ? _a : uniqueName,
145
+ priority: (_b = props.priority) !== null && _b !== void 0 ? _b : coreTokenizer.TokenizerPriority.LINKS,
146
+ });
147
+ this.match = match;
148
+ this.parse = parse;
133
149
  }
134
150
  }
135
151
 
136
152
  exports.ImageTokenizer = ImageTokenizer;
137
153
  exports.ImageTokenizerName = uniqueName;
138
154
  exports.calcImageAlt = calcImageAlt;
139
- exports['default'] = ImageTokenizer;
155
+ exports["default"] = ImageTokenizer;
156
+ exports.imageMatch = match;
157
+ exports.imageParse = parse;
package/lib/esm/index.js CHANGED
@@ -1,10 +1,8 @@
1
1
  import { ImageType } from '@yozora/ast';
2
2
  import { AsciiCodePoint, calcEscapedStringFromNodePoints } from '@yozora/character';
3
- import { BaseInlineTokenizer, TokenizerPriority, eatOptionalWhitespaces, encodeLinkDestination } from '@yozora/core-tokenizer';
3
+ import { genFindDelimiter, eatOptionalWhitespaces, encodeLinkDestination, BaseInlineTokenizer, TokenizerPriority } from '@yozora/core-tokenizer';
4
4
  import { eatLinkDestination, eatLinkTitle, checkBalancedBracketsStatus } from '@yozora/tokenizer-link';
5
5
 
6
- const uniqueName = '@yozora/tokenizer-image';
7
-
8
6
  function calcImageAlt(nodes) {
9
7
  return nodes
10
8
  .map((o) => {
@@ -19,15 +17,14 @@ function calcImageAlt(nodes) {
19
17
  .join('');
20
18
  }
21
19
 
22
- class ImageTokenizer extends BaseInlineTokenizer {
23
- constructor(props = {}) {
24
- var _a, _b;
25
- super({
26
- name: (_a = props.name) !== null && _a !== void 0 ? _a : uniqueName,
27
- priority: (_b = props.priority) !== null && _b !== void 0 ? _b : TokenizerPriority.LINKS,
28
- });
29
- }
30
- _findDelimiter(startIndex, endIndex, nodePoints, api) {
20
+ const match = function (api) {
21
+ return {
22
+ findDelimiter: () => genFindDelimiter(_findDelimiter),
23
+ isDelimiterPair,
24
+ processDelimiterPair,
25
+ };
26
+ function _findDelimiter(startIndex, endIndex) {
27
+ const nodePoints = api.getNodePoints();
31
28
  const blockEndIndex = api.getBlockEndIndex();
32
29
  for (let i = startIndex; i < endIndex; ++i) {
33
30
  const c = nodePoints[i].codePoint;
@@ -36,8 +33,7 @@ class ImageTokenizer extends BaseInlineTokenizer {
36
33
  i += 1;
37
34
  break;
38
35
  case AsciiCodePoint.EXCLAMATION_MARK: {
39
- if (i + 1 < endIndex &&
40
- nodePoints[i + 1].codePoint === AsciiCodePoint.OPEN_BRACKET) {
36
+ if (i + 1 < endIndex && nodePoints[i + 1].codePoint === AsciiCodePoint.OPEN_BRACKET) {
41
37
  return {
42
38
  type: 'opener',
43
39
  startIndex: i,
@@ -62,8 +58,7 @@ class ImageTokenizer extends BaseInlineTokenizer {
62
58
  const _startIndex = i;
63
59
  const _endIndex = eatOptionalWhitespaces(nodePoints, titleEndIndex, blockEndIndex) + 1;
64
60
  if (_endIndex > blockEndIndex ||
65
- nodePoints[_endIndex - 1].codePoint !==
66
- AsciiCodePoint.CLOSE_PARENTHESIS) {
61
+ nodePoints[_endIndex - 1].codePoint !== AsciiCodePoint.CLOSE_PARENTHESIS) {
67
62
  break;
68
63
  }
69
64
  return {
@@ -85,7 +80,8 @@ class ImageTokenizer extends BaseInlineTokenizer {
85
80
  }
86
81
  return null;
87
82
  }
88
- isDelimiterPair(openerDelimiter, closerDelimiter, internalTokens, nodePoints) {
83
+ function isDelimiterPair(openerDelimiter, closerDelimiter, internalTokens) {
84
+ const nodePoints = api.getNodePoints();
89
85
  const balancedBracketsStatus = checkBalancedBracketsStatus(openerDelimiter.endIndex, closerDelimiter.startIndex, internalTokens, nodePoints);
90
86
  switch (balancedBracketsStatus) {
91
87
  case -1:
@@ -96,37 +92,57 @@ class ImageTokenizer extends BaseInlineTokenizer {
96
92
  return { paired: false, opener: true, closer: false };
97
93
  }
98
94
  }
99
- processDelimiterPair(openerDelimiter, closerDelimiter, internalTokens, nodePoints, api) {
95
+ function processDelimiterPair(openerDelimiter, closerDelimiter, internalTokens) {
100
96
  const token = {
101
97
  nodeType: ImageType,
102
98
  startIndex: openerDelimiter.startIndex,
103
99
  endIndex: closerDelimiter.endIndex,
104
100
  destinationContent: closerDelimiter.destinationContent,
105
101
  titleContent: closerDelimiter.titleContent,
106
- children: api.resolveInternalTokens(internalTokens, openerDelimiter.endIndex, closerDelimiter.startIndex, nodePoints),
102
+ children: api.resolveInternalTokens(internalTokens, openerDelimiter.endIndex, closerDelimiter.startIndex),
107
103
  };
108
104
  return { tokens: [token] };
109
105
  }
110
- processToken(token, children, nodePoints) {
111
- let url = '';
112
- if (token.destinationContent != null) {
113
- let { startIndex, endIndex } = token.destinationContent;
114
- if (nodePoints[startIndex].codePoint === AsciiCodePoint.OPEN_ANGLE) {
115
- startIndex += 1;
116
- endIndex -= 1;
106
+ };
107
+
108
+ const parse = function (api) {
109
+ return {
110
+ parse: (token, children) => {
111
+ const nodePoints = api.getNodePoints();
112
+ let url = '';
113
+ if (token.destinationContent != null) {
114
+ let { startIndex, endIndex } = token.destinationContent;
115
+ if (nodePoints[startIndex].codePoint === AsciiCodePoint.OPEN_ANGLE) {
116
+ startIndex += 1;
117
+ endIndex -= 1;
118
+ }
119
+ const destination = calcEscapedStringFromNodePoints(nodePoints, startIndex, endIndex, true);
120
+ url = encodeLinkDestination(destination);
117
121
  }
118
- const destination = calcEscapedStringFromNodePoints(nodePoints, startIndex, endIndex, true);
119
- url = encodeLinkDestination(destination);
120
- }
121
- const alt = calcImageAlt(children || []);
122
- let title;
123
- if (token.titleContent != null) {
124
- const { startIndex, endIndex } = token.titleContent;
125
- title = calcEscapedStringFromNodePoints(nodePoints, startIndex + 1, endIndex - 1);
126
- }
127
- const result = { type: ImageType, url, alt, title };
128
- return result;
122
+ const alt = calcImageAlt(children);
123
+ let title;
124
+ if (token.titleContent != null) {
125
+ const { startIndex, endIndex } = token.titleContent;
126
+ title = calcEscapedStringFromNodePoints(nodePoints, startIndex + 1, endIndex - 1);
127
+ }
128
+ const result = { type: ImageType, url, alt, title };
129
+ return result;
130
+ },
131
+ };
132
+ };
133
+
134
+ const uniqueName = '@yozora/tokenizer-image';
135
+
136
+ class ImageTokenizer extends BaseInlineTokenizer {
137
+ constructor(props = {}) {
138
+ var _a, _b;
139
+ super({
140
+ name: (_a = props.name) !== null && _a !== void 0 ? _a : uniqueName,
141
+ priority: (_b = props.priority) !== null && _b !== void 0 ? _b : TokenizerPriority.LINKS,
142
+ });
143
+ this.match = match;
144
+ this.parse = parse;
129
145
  }
130
146
  }
131
147
 
132
- export { ImageTokenizer, uniqueName as ImageTokenizerName, calcImageAlt, ImageTokenizer as default };
148
+ export { ImageTokenizer, uniqueName as ImageTokenizerName, calcImageAlt, ImageTokenizer as default, match as imageMatch, parse as imageParse };
@@ -1,6 +1,6 @@
1
- import { ImageTokenizer } from './tokenizer';
2
1
  export * from './util';
3
- export { ImageTokenizer } from './tokenizer';
2
+ export { match as imageMatch } from './match';
3
+ export { parse as imageParse } from './parse';
4
+ export { ImageTokenizer, ImageTokenizer as default } from './tokenizer';
4
5
  export { uniqueName as ImageTokenizerName } from './types';
5
- export type { Token as ImageToken, TokenizerProps as ImageTokenizerProps, } from './types';
6
- export default ImageTokenizer;
6
+ export type { IThis as IImageHookContext, IToken as IImageToken, ITokenizerProps as IImageTokenizerProps, } from './types';
@@ -0,0 +1,30 @@
1
+ import type { IMatchInlineHookCreator } from '@yozora/core-tokenizer';
2
+ import type { IDelimiter, IThis, IToken, T } from './types';
3
+ /**
4
+ * Syntax for images is like the syntax for links, with one difference.
5
+ * Instead of link text, we have an image description.
6
+ * The rules for 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
+ * ------
15
+ *
16
+ * A 'opener' type delimiter is one of the following forms:
17
+ *
18
+ * - '!['
19
+ *
20
+ * A 'closer' type delimiter is one of the following forms:
21
+ *
22
+ * - '](url)'
23
+ * - '](url "title")'
24
+ * - '](<url>)'
25
+ * - '](<url> "title")'
26
+ *
27
+ * @see https://github.com/syntax-tree/mdast#image
28
+ * @see https://github.github.com/gfm/#images
29
+ */
30
+ export declare const match: IMatchInlineHookCreator<T, IDelimiter, IToken, IThis>;
@@ -0,0 +1,3 @@
1
+ import type { IParseInlineHookCreator } from '@yozora/core-tokenizer';
2
+ import type { INode, IThis, IToken, T } from './types';
3
+ export declare const parse: IParseInlineHookCreator<T, IToken, INode, IThis>;
@@ -1,69 +1,13 @@
1
- import type { YastNode } from '@yozora/ast';
2
- import type { NodePoint } from '@yozora/character';
3
- import type { MatchInlinePhaseApi, ResultOfIsDelimiterPair, ResultOfProcessDelimiterPair, Tokenizer, TokenizerMatchInlineHook, TokenizerParseInlineHook, YastInlineToken } from '@yozora/core-tokenizer';
1
+ import type { IInlineTokenizer, IMatchInlineHookCreator, IParseInlineHookCreator } from '@yozora/core-tokenizer';
4
2
  import { BaseInlineTokenizer } from '@yozora/core-tokenizer';
5
- import type { Delimiter, Node, T, Token, TokenizerProps } from './types';
3
+ import type { IDelimiter, INode, IThis, IToken, ITokenizerProps, T } from './types';
6
4
  /**
7
5
  * Lexical Analyzer for InlineImage.
8
- *
9
- * Syntax for images is like the syntax for links, with one difference.
10
- * Instead of link text, we have an image description.
11
- * The rules for this are the same as for link text, except that
12
- *
13
- * a) an image description starts with '![' rather than '[', and
14
- * b) an image description may contain links.
15
- *
16
- * An image description has inline elements as its contents. When an image is
17
- * rendered to HTML, this is standardly used as the image’s alt attribute.
18
- *
19
- * ------
20
- *
21
- * A 'opener' type delimiter is one of the following forms:
22
- *
23
- * - '!['
24
- *
25
- * A 'closer' type delimiter is one of the following forms:
26
- *
27
- * - '](url)'
28
- * - '](url "title")'
29
- * - '](<url>)'
30
- * - '](<url> "title")'
31
- *
32
6
  * @see https://github.com/syntax-tree/mdast#image
33
7
  * @see https://github.github.com/gfm/#images
34
8
  */
35
- export declare class ImageTokenizer extends BaseInlineTokenizer<Delimiter> implements Tokenizer, TokenizerMatchInlineHook<T, Delimiter, Token>, TokenizerParseInlineHook<T, Token, Node> {
36
- constructor(props?: TokenizerProps);
37
- /**
38
- * Images can contains Images, so implement an algorithm similar to bracket
39
- * matching, pushing all opener delimiters onto the stack
40
- *
41
- * The rules for this are the same as for link text, except that
42
- * (a) an image description starts with '![' rather than '[', and
43
- * (b) an image description may contain links. An image description has
44
- * inline elements as its contents. When an image is rendered to HTML,
45
- * this is standardly used as the image’s alt attribute
46
- *
47
- * @see https://github.github.com/gfm/#inline-link
48
- * @see https://github.github.com/gfm/#example-582
49
- *
50
- * @override
51
- * @see TokenizerMatchInlineHook
52
- */
53
- protected _findDelimiter(startIndex: number, endIndex: number, nodePoints: ReadonlyArray<NodePoint>, api: Readonly<MatchInlinePhaseApi>): Delimiter | null;
54
- /**
55
- * @override
56
- * @see TokenizerMatchInlineHook
57
- */
58
- isDelimiterPair(openerDelimiter: Delimiter, closerDelimiter: Delimiter, internalTokens: ReadonlyArray<YastInlineToken>, nodePoints: ReadonlyArray<NodePoint>): ResultOfIsDelimiterPair;
59
- /**
60
- * @override
61
- * @see TokenizerMatchInlineHook
62
- */
63
- processDelimiterPair(openerDelimiter: Delimiter, closerDelimiter: Delimiter, internalTokens: ReadonlyArray<YastInlineToken>, nodePoints: ReadonlyArray<NodePoint>, api: Readonly<MatchInlinePhaseApi>): ResultOfProcessDelimiterPair<T, Token, Delimiter>;
64
- /**
65
- * @override
66
- * @see TokenizerParseInlineHook
67
- */
68
- processToken(token: Token, children: YastNode[] | undefined, nodePoints: ReadonlyArray<NodePoint>): Node;
9
+ export declare class ImageTokenizer 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>;
69
13
  }
@@ -1,34 +1,35 @@
1
- import type { Image, ImageType } from '@yozora/ast';
2
- import type { NodeInterval } from '@yozora/character';
3
- import type { BaseInlineTokenizerProps, PartialYastInlineToken, YastTokenDelimiter } from '@yozora/core-tokenizer';
1
+ import type { IImage, ImageType } from '@yozora/ast';
2
+ import type { INodeInterval } from '@yozora/character';
3
+ import type { IBaseInlineTokenizerProps, IPartialYastInlineToken, ITokenizer, IYastTokenDelimiter } from '@yozora/core-tokenizer';
4
4
  export declare type T = ImageType;
5
- export declare type Node = Image;
5
+ export declare type INode = IImage;
6
6
  export declare const uniqueName = "@yozora/tokenizer-image";
7
7
  /**
8
8
  * An image token.
9
9
  */
10
- export interface Token extends PartialYastInlineToken<T> {
10
+ export interface IToken extends IPartialYastInlineToken<T> {
11
11
  /**
12
12
  * Link destination interval.
13
13
  */
14
- destinationContent?: NodeInterval;
14
+ destinationContent?: INodeInterval;
15
15
  /**
16
16
  * Link title interval.
17
17
  */
18
- titleContent?: NodeInterval;
18
+ titleContent?: INodeInterval;
19
19
  }
20
- export interface Delimiter extends YastTokenDelimiter {
20
+ export interface IDelimiter extends IYastTokenDelimiter {
21
21
  /**
22
- * Delimiter type.
22
+ * IDelimiter type.
23
23
  */
24
24
  type: 'opener' | 'closer';
25
25
  /**
26
26
  * link destination
27
27
  */
28
- destinationContent?: NodeInterval;
28
+ destinationContent?: INodeInterval;
29
29
  /**
30
30
  * link title
31
31
  */
32
- titleContent?: NodeInterval;
32
+ titleContent?: INodeInterval;
33
33
  }
34
- export declare type TokenizerProps = Partial<BaseInlineTokenizerProps>;
34
+ export declare type IThis = ITokenizer;
35
+ export declare type ITokenizerProps = Partial<IBaseInlineTokenizerProps>;
@@ -1,8 +1,8 @@
1
- import type { YastNode } from '@yozora/ast';
1
+ import type { IYastNode } from '@yozora/ast';
2
2
  /**
3
3
  * calc alt
4
4
  * An image description has inline elements as its contents. When an image
5
5
  * is rendered to HTML, this is standardly used as the image’s alt attribute
6
6
  * @see https://github.github.com/gfm/#example-582
7
7
  */
8
- export declare function calcImageAlt(nodes: ReadonlyArray<YastNode>): string;
8
+ export declare function calcImageAlt(nodes: ReadonlyArray<IYastNode>): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yozora/tokenizer-image",
3
- "version": "1.2.1",
3
+ "version": "2.0.0-alpha.1",
4
4
  "author": {
5
5
  "name": "guanghechen",
6
6
  "url": "https://github.com/guanghechen/"
@@ -35,10 +35,10 @@
35
35
  "test": "cross-env TS_NODE_FILES=true jest --config ../../jest.config.js --rootDir ."
36
36
  },
37
37
  "dependencies": {
38
- "@yozora/ast": "^1.2.1",
39
- "@yozora/character": "^1.2.1",
40
- "@yozora/core-tokenizer": "^1.2.1",
41
- "@yozora/tokenizer-link": "^1.2.1"
38
+ "@yozora/ast": "^2.0.0-alpha.1",
39
+ "@yozora/character": "^2.0.0-alpha.1",
40
+ "@yozora/core-tokenizer": "^2.0.0-alpha.1",
41
+ "@yozora/tokenizer-link": "^2.0.0-alpha.1"
42
42
  },
43
- "gitHead": "d98d07d7c56dd9f6bb60149b2b0a4be2787e1046"
43
+ "gitHead": "86202e1d2b03ccfc2ab030517d9d314f7aee7666"
44
44
  }