@yozora/tokenizer-html-inline 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 HtmlInlineTokenizer from '@yozora/tokenizer-html-inline'
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 HtmlInlineTokenizer())
96
96
 
97
97
  // parse source markdown content
@@ -229,7 +229,6 @@ Name | Type | Required | Default
229
229
  [@yozora/tokenizer-link]: https://github.com/yozorajs/yozora/tree/main/tokenizers/link#readme
230
230
  [@yozora/tokenizer-link-reference]: https://github.com/yozorajs/yozora/tree/main/tokenizers/link-reference#readme
231
231
  [@yozora/tokenizer-list]: https://github.com/yozorajs/yozora/tree/main/tokenizers/list#readme
232
- [@yozora/tokenizer-list-item]: https://github.com/yozorajs/yozora/tree/main/tokenizers/list-item#readme
233
232
  [@yozora/tokenizer-math]: https://github.com/yozorajs/yozora/tree/main/tokenizers/math#readme
234
233
  [@yozora/tokenizer-paragraph]: https://github.com/yozorajs/yozora/tree/main/tokenizers/paragraph#readme
235
234
  [@yozora/tokenizer-setext-heading]: https://github.com/yozorajs/yozora/tree/main/tokenizers/setext-heading#readme
@@ -289,7 +288,6 @@ Name | Type | Required | Default
289
288
  [doc-@yozora/tokenizer-definition]: https://yozora.guanghechen.com/docs/package/tokenizer-definition
290
289
  [doc-@yozora/tokenizer-link-reference]: https://yozora.guanghechen.com/docs/package/tokenizer-link-reference
291
290
  [doc-@yozora/tokenizer-list]: https://yozora.guanghechen.com/docs/package/tokenizer-list
292
- [doc-@yozora/tokenizer-list-item]: https://yozora.guanghechen.com/docs/package/tokenizer-list-item
293
291
  [doc-@yozora/tokenizer-math]: https://yozora.guanghechen.com/docs/package/tokenizer-math
294
292
  [doc-@yozora/tokenizer-paragraph]: https://yozora.guanghechen.com/docs/package/tokenizer-paragraph
295
293
  [doc-@yozora/tokenizer-setext-heading]: https://yozora.guanghechen.com/docs/package/tokenizer-setext-heading
package/lib/cjs/index.js CHANGED
@@ -2,12 +2,10 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var ast = require('@yozora/ast');
6
5
  var character = require('@yozora/character');
7
6
  var coreTokenizer = require('@yozora/core-tokenizer');
8
7
  var tokenizerHtmlBlock = require('@yozora/tokenizer-html-block');
9
-
10
- const uniqueName = '@yozora/tokenizer-html-inline';
8
+ var ast = require('@yozora/ast');
11
9
 
12
10
  function eatHtmlInlineCDataDelimiter(nodePoints, startIndex, endIndex) {
13
11
  let i = startIndex;
@@ -108,8 +106,7 @@ function eatHtmlInlineCommentDelimiter(nodePoints, startIndex, endIndex) {
108
106
 
109
107
  function eatHtmlInlineDeclarationDelimiter(nodePoints, startIndex, endIndex) {
110
108
  let i = startIndex;
111
- if (i + 4 >= endIndex ||
112
- nodePoints[i + 1].codePoint !== character.AsciiCodePoint.EXCLAMATION_MARK)
109
+ if (i + 4 >= endIndex || nodePoints[i + 1].codePoint !== character.AsciiCodePoint.EXCLAMATION_MARK)
113
110
  return null;
114
111
  const tagNameStartIndex = i + 2;
115
112
  for (i = tagNameStartIndex; i < endIndex; ++i) {
@@ -143,8 +140,7 @@ function eatHtmlInlineDeclarationDelimiter(nodePoints, startIndex, endIndex) {
143
140
 
144
141
  function eatHtmlInlineInstructionDelimiter(nodePoints, startIndex, endIndex) {
145
142
  let i = startIndex;
146
- if (i + 3 >= endIndex ||
147
- nodePoints[i + 1].codePoint !== character.AsciiCodePoint.QUESTION_MARK)
143
+ if (i + 3 >= endIndex || nodePoints[i + 1].codePoint !== character.AsciiCodePoint.QUESTION_MARK)
148
144
  return null;
149
145
  const si = i + 2;
150
146
  for (i = si; i < endIndex; ++i) {
@@ -207,15 +203,13 @@ function eatHtmlInlineTokenOpenDelimiter(nodePoints, startIndex, endIndex) {
207
203
  return delimiter;
208
204
  }
209
205
 
210
- class HtmlInlineTokenizer extends coreTokenizer.BaseInlineTokenizer {
211
- constructor(props = {}) {
212
- var _a, _b;
213
- super({
214
- name: (_a = props.name) !== null && _a !== void 0 ? _a : uniqueName,
215
- priority: (_b = props.priority) !== null && _b !== void 0 ? _b : coreTokenizer.TokenizerPriority.ATOMIC,
216
- });
217
- }
218
- _findDelimiter(startIndex, endIndex, nodePoints) {
206
+ const match = function (api) {
207
+ return {
208
+ findDelimiter: () => coreTokenizer.genFindDelimiter(_findDelimiter),
209
+ processSingleDelimiter,
210
+ };
211
+ function _findDelimiter(startIndex, endIndex) {
212
+ const nodePoints = api.getNodePoints();
219
213
  for (let i = startIndex; i < endIndex; ++i) {
220
214
  i = coreTokenizer.eatOptionalWhitespaces(nodePoints, i, endIndex);
221
215
  if (i >= endIndex)
@@ -226,7 +220,7 @@ class HtmlInlineTokenizer extends coreTokenizer.BaseInlineTokenizer {
226
220
  i += 1;
227
221
  break;
228
222
  case character.AsciiCodePoint.OPEN_ANGLE: {
229
- const delimiter = this.tryToEatDelimiter(nodePoints, i, endIndex);
223
+ const delimiter = tryToEatDelimiter(nodePoints, i, endIndex);
230
224
  if (delimiter != null)
231
225
  return delimiter;
232
226
  break;
@@ -235,44 +229,66 @@ class HtmlInlineTokenizer extends coreTokenizer.BaseInlineTokenizer {
235
229
  }
236
230
  return null;
237
231
  }
238
- processSingleDelimiter(delimiter) {
232
+ function processSingleDelimiter(delimiter) {
239
233
  const token = Object.assign(Object.assign({}, delimiter), { nodeType: ast.HtmlType });
240
234
  return [token];
241
235
  }
242
- processToken(token, children, nodePoints) {
243
- const { startIndex, endIndex } = token;
244
- const value = character.calcStringFromNodePoints(nodePoints, startIndex, endIndex);
245
- const result = { type: ast.HtmlType, value };
246
- return result;
247
- }
248
- tryToEatDelimiter(nodePoints, startIndex, endIndex) {
249
- let delimiter = null;
250
- delimiter = eatHtmlInlineTokenOpenDelimiter(nodePoints, startIndex, endIndex);
251
- if (delimiter != null)
252
- return delimiter;
253
- delimiter = eatHtmlInlineClosingDelimiter(nodePoints, startIndex, endIndex);
254
- if (delimiter != null)
255
- return delimiter;
256
- delimiter = eatHtmlInlineCommentDelimiter(nodePoints, startIndex, endIndex);
257
- if (delimiter != null)
258
- return delimiter;
259
- delimiter = eatHtmlInlineInstructionDelimiter(nodePoints, startIndex, endIndex);
260
- if (delimiter != null)
261
- return delimiter;
262
- delimiter = eatHtmlInlineDeclarationDelimiter(nodePoints, startIndex, endIndex);
263
- if (delimiter != null)
264
- return delimiter;
265
- delimiter = eatHtmlInlineCDataDelimiter(nodePoints, startIndex, endIndex);
236
+ };
237
+ function tryToEatDelimiter(nodePoints, startIndex, endIndex) {
238
+ let delimiter = null;
239
+ delimiter = eatHtmlInlineTokenOpenDelimiter(nodePoints, startIndex, endIndex);
240
+ if (delimiter != null)
266
241
  return delimiter;
242
+ delimiter = eatHtmlInlineClosingDelimiter(nodePoints, startIndex, endIndex);
243
+ if (delimiter != null)
244
+ return delimiter;
245
+ delimiter = eatHtmlInlineCommentDelimiter(nodePoints, startIndex, endIndex);
246
+ if (delimiter != null)
247
+ return delimiter;
248
+ delimiter = eatHtmlInlineInstructionDelimiter(nodePoints, startIndex, endIndex);
249
+ if (delimiter != null)
250
+ return delimiter;
251
+ delimiter = eatHtmlInlineDeclarationDelimiter(nodePoints, startIndex, endIndex);
252
+ if (delimiter != null)
253
+ return delimiter;
254
+ delimiter = eatHtmlInlineCDataDelimiter(nodePoints, startIndex, endIndex);
255
+ return delimiter;
256
+ }
257
+
258
+ const parse = function (api) {
259
+ return {
260
+ parse: token => {
261
+ const { startIndex, endIndex } = token;
262
+ const nodePoints = api.getNodePoints();
263
+ const value = character.calcStringFromNodePoints(nodePoints, startIndex, endIndex);
264
+ const result = { type: ast.HtmlType, value };
265
+ return result;
266
+ },
267
+ };
268
+ };
269
+
270
+ const uniqueName = '@yozora/tokenizer-html-inline';
271
+
272
+ class HtmlInlineTokenizer extends coreTokenizer.BaseInlineTokenizer {
273
+ constructor(props = {}) {
274
+ var _a, _b;
275
+ super({
276
+ name: (_a = props.name) !== null && _a !== void 0 ? _a : uniqueName,
277
+ priority: (_b = props.priority) !== null && _b !== void 0 ? _b : coreTokenizer.TokenizerPriority.ATOMIC,
278
+ });
279
+ this.match = match;
280
+ this.parse = parse;
267
281
  }
268
282
  }
269
283
 
270
284
  exports.HtmlInlineTokenizer = HtmlInlineTokenizer;
271
285
  exports.HtmlInlineTokenizerName = uniqueName;
272
- exports['default'] = HtmlInlineTokenizer;
286
+ exports["default"] = HtmlInlineTokenizer;
273
287
  exports.eatHtmlInlineCDataDelimiter = eatHtmlInlineCDataDelimiter;
274
288
  exports.eatHtmlInlineClosingDelimiter = eatHtmlInlineClosingDelimiter;
275
289
  exports.eatHtmlInlineCommentDelimiter = eatHtmlInlineCommentDelimiter;
276
290
  exports.eatHtmlInlineDeclarationDelimiter = eatHtmlInlineDeclarationDelimiter;
277
291
  exports.eatHtmlInlineInstructionDelimiter = eatHtmlInlineInstructionDelimiter;
278
292
  exports.eatHtmlInlineTokenOpenDelimiter = eatHtmlInlineTokenOpenDelimiter;
293
+ exports.htmlInlineMatch = match;
294
+ exports.htmlInlineParse = parse;
package/lib/esm/index.js CHANGED
@@ -1,9 +1,7 @@
1
- import { HtmlType } from '@yozora/ast';
2
1
  import { AsciiCodePoint, isAsciiUpperLetter, isWhitespaceCharacter, calcStringFromNodePoints } from '@yozora/character';
3
- import { eatOptionalWhitespaces, BaseInlineTokenizer, TokenizerPriority } from '@yozora/core-tokenizer';
2
+ import { eatOptionalWhitespaces, genFindDelimiter, BaseInlineTokenizer, TokenizerPriority } from '@yozora/core-tokenizer';
4
3
  import { eatHTMLTagName, eatHTMLAttribute } from '@yozora/tokenizer-html-block';
5
-
6
- const uniqueName = '@yozora/tokenizer-html-inline';
4
+ import { HtmlType } from '@yozora/ast';
7
5
 
8
6
  function eatHtmlInlineCDataDelimiter(nodePoints, startIndex, endIndex) {
9
7
  let i = startIndex;
@@ -104,8 +102,7 @@ function eatHtmlInlineCommentDelimiter(nodePoints, startIndex, endIndex) {
104
102
 
105
103
  function eatHtmlInlineDeclarationDelimiter(nodePoints, startIndex, endIndex) {
106
104
  let i = startIndex;
107
- if (i + 4 >= endIndex ||
108
- nodePoints[i + 1].codePoint !== AsciiCodePoint.EXCLAMATION_MARK)
105
+ if (i + 4 >= endIndex || nodePoints[i + 1].codePoint !== AsciiCodePoint.EXCLAMATION_MARK)
109
106
  return null;
110
107
  const tagNameStartIndex = i + 2;
111
108
  for (i = tagNameStartIndex; i < endIndex; ++i) {
@@ -139,8 +136,7 @@ function eatHtmlInlineDeclarationDelimiter(nodePoints, startIndex, endIndex) {
139
136
 
140
137
  function eatHtmlInlineInstructionDelimiter(nodePoints, startIndex, endIndex) {
141
138
  let i = startIndex;
142
- if (i + 3 >= endIndex ||
143
- nodePoints[i + 1].codePoint !== AsciiCodePoint.QUESTION_MARK)
139
+ if (i + 3 >= endIndex || nodePoints[i + 1].codePoint !== AsciiCodePoint.QUESTION_MARK)
144
140
  return null;
145
141
  const si = i + 2;
146
142
  for (i = si; i < endIndex; ++i) {
@@ -203,15 +199,13 @@ function eatHtmlInlineTokenOpenDelimiter(nodePoints, startIndex, endIndex) {
203
199
  return delimiter;
204
200
  }
205
201
 
206
- class HtmlInlineTokenizer extends BaseInlineTokenizer {
207
- constructor(props = {}) {
208
- var _a, _b;
209
- super({
210
- name: (_a = props.name) !== null && _a !== void 0 ? _a : uniqueName,
211
- priority: (_b = props.priority) !== null && _b !== void 0 ? _b : TokenizerPriority.ATOMIC,
212
- });
213
- }
214
- _findDelimiter(startIndex, endIndex, nodePoints) {
202
+ const match = function (api) {
203
+ return {
204
+ findDelimiter: () => genFindDelimiter(_findDelimiter),
205
+ processSingleDelimiter,
206
+ };
207
+ function _findDelimiter(startIndex, endIndex) {
208
+ const nodePoints = api.getNodePoints();
215
209
  for (let i = startIndex; i < endIndex; ++i) {
216
210
  i = eatOptionalWhitespaces(nodePoints, i, endIndex);
217
211
  if (i >= endIndex)
@@ -222,7 +216,7 @@ class HtmlInlineTokenizer extends BaseInlineTokenizer {
222
216
  i += 1;
223
217
  break;
224
218
  case AsciiCodePoint.OPEN_ANGLE: {
225
- const delimiter = this.tryToEatDelimiter(nodePoints, i, endIndex);
219
+ const delimiter = tryToEatDelimiter(nodePoints, i, endIndex);
226
220
  if (delimiter != null)
227
221
  return delimiter;
228
222
  break;
@@ -231,36 +225,56 @@ class HtmlInlineTokenizer extends BaseInlineTokenizer {
231
225
  }
232
226
  return null;
233
227
  }
234
- processSingleDelimiter(delimiter) {
228
+ function processSingleDelimiter(delimiter) {
235
229
  const token = Object.assign(Object.assign({}, delimiter), { nodeType: HtmlType });
236
230
  return [token];
237
231
  }
238
- processToken(token, children, nodePoints) {
239
- const { startIndex, endIndex } = token;
240
- const value = calcStringFromNodePoints(nodePoints, startIndex, endIndex);
241
- const result = { type: HtmlType, value };
242
- return result;
243
- }
244
- tryToEatDelimiter(nodePoints, startIndex, endIndex) {
245
- let delimiter = null;
246
- delimiter = eatHtmlInlineTokenOpenDelimiter(nodePoints, startIndex, endIndex);
247
- if (delimiter != null)
248
- return delimiter;
249
- delimiter = eatHtmlInlineClosingDelimiter(nodePoints, startIndex, endIndex);
250
- if (delimiter != null)
251
- return delimiter;
252
- delimiter = eatHtmlInlineCommentDelimiter(nodePoints, startIndex, endIndex);
253
- if (delimiter != null)
254
- return delimiter;
255
- delimiter = eatHtmlInlineInstructionDelimiter(nodePoints, startIndex, endIndex);
256
- if (delimiter != null)
257
- return delimiter;
258
- delimiter = eatHtmlInlineDeclarationDelimiter(nodePoints, startIndex, endIndex);
259
- if (delimiter != null)
260
- return delimiter;
261
- delimiter = eatHtmlInlineCDataDelimiter(nodePoints, startIndex, endIndex);
232
+ };
233
+ function tryToEatDelimiter(nodePoints, startIndex, endIndex) {
234
+ let delimiter = null;
235
+ delimiter = eatHtmlInlineTokenOpenDelimiter(nodePoints, startIndex, endIndex);
236
+ if (delimiter != null)
262
237
  return delimiter;
238
+ delimiter = eatHtmlInlineClosingDelimiter(nodePoints, startIndex, endIndex);
239
+ if (delimiter != null)
240
+ return delimiter;
241
+ delimiter = eatHtmlInlineCommentDelimiter(nodePoints, startIndex, endIndex);
242
+ if (delimiter != null)
243
+ return delimiter;
244
+ delimiter = eatHtmlInlineInstructionDelimiter(nodePoints, startIndex, endIndex);
245
+ if (delimiter != null)
246
+ return delimiter;
247
+ delimiter = eatHtmlInlineDeclarationDelimiter(nodePoints, startIndex, endIndex);
248
+ if (delimiter != null)
249
+ return delimiter;
250
+ delimiter = eatHtmlInlineCDataDelimiter(nodePoints, startIndex, endIndex);
251
+ return delimiter;
252
+ }
253
+
254
+ const parse = function (api) {
255
+ return {
256
+ parse: token => {
257
+ const { startIndex, endIndex } = token;
258
+ const nodePoints = api.getNodePoints();
259
+ const value = calcStringFromNodePoints(nodePoints, startIndex, endIndex);
260
+ const result = { type: HtmlType, value };
261
+ return result;
262
+ },
263
+ };
264
+ };
265
+
266
+ const uniqueName = '@yozora/tokenizer-html-inline';
267
+
268
+ class HtmlInlineTokenizer extends BaseInlineTokenizer {
269
+ constructor(props = {}) {
270
+ var _a, _b;
271
+ super({
272
+ name: (_a = props.name) !== null && _a !== void 0 ? _a : uniqueName,
273
+ priority: (_b = props.priority) !== null && _b !== void 0 ? _b : TokenizerPriority.ATOMIC,
274
+ });
275
+ this.match = match;
276
+ this.parse = parse;
263
277
  }
264
278
  }
265
279
 
266
- export { HtmlInlineTokenizer, uniqueName as HtmlInlineTokenizerName, HtmlInlineTokenizer as default, eatHtmlInlineCDataDelimiter, eatHtmlInlineClosingDelimiter, eatHtmlInlineCommentDelimiter, eatHtmlInlineDeclarationDelimiter, eatHtmlInlineInstructionDelimiter, eatHtmlInlineTokenOpenDelimiter };
280
+ export { HtmlInlineTokenizer, uniqueName as HtmlInlineTokenizerName, HtmlInlineTokenizer as default, eatHtmlInlineCDataDelimiter, eatHtmlInlineClosingDelimiter, eatHtmlInlineCommentDelimiter, eatHtmlInlineDeclarationDelimiter, eatHtmlInlineInstructionDelimiter, eatHtmlInlineTokenOpenDelimiter, match as htmlInlineMatch, parse as htmlInlineParse };
@@ -1,11 +1,11 @@
1
- import { HtmlInlineTokenizer } from './tokenizer';
2
1
  export * from './util/cdata';
3
2
  export * from './util/closing';
4
3
  export * from './util/comment';
5
4
  export * from './util/declaration';
6
5
  export * from './util/instruction';
7
6
  export * from './util/open';
8
- export { HtmlInlineTokenizer } from './tokenizer';
7
+ export { match as htmlInlineMatch } from './match';
8
+ export { parse as htmlInlineParse } from './parse';
9
+ export { HtmlInlineTokenizer, HtmlInlineTokenizer as default } from './tokenizer';
9
10
  export { uniqueName as HtmlInlineTokenizerName } from './types';
10
- export type { Token as HtmlInlineToken, TokenizerProps as HtmlInlineTokenizerProps, } from './types';
11
- export default HtmlInlineTokenizer;
11
+ export type { IThis as IHtmlInlineHookContext, IToken as IHtmlInlineToken, ITokenizerProps as IHtmlInlineTokenizerProps, } from './types';
@@ -0,0 +1,11 @@
1
+ import type { IMatchInlineHookCreator } from '@yozora/core-tokenizer';
2
+ import type { IDelimiter, IThis, IToken, T } from './types';
3
+ /**
4
+ * Text between '<' and '>' that looks like an HTML tag is parsed as a raw HTML
5
+ * tag and will be rendered in HTML without escaping. Tag and attribute names
6
+ * are not limited to current HTML tags, so custom tags (and even, say, DocBook
7
+ * tags) may be used.
8
+ *
9
+ * @see https://github.github.com/gfm/#raw-html
10
+ */
11
+ 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,8 +1,6 @@
1
- import type { YastNode } from '@yozora/ast';
2
- import type { NodePoint } from '@yozora/character';
3
- import type { ResultOfProcessSingleDelimiter, Tokenizer, TokenizerMatchInlineHook, TokenizerParseInlineHook } 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 HtmlInline.
8
6
  *
@@ -13,29 +11,8 @@ import type { Delimiter, Node, T, Token, TokenizerProps } from './types';
13
11
  *
14
12
  * @see https://github.github.com/gfm/#raw-html
15
13
  */
16
- export declare class HtmlInlineTokenizer extends BaseInlineTokenizer<Delimiter> implements Tokenizer, TokenizerMatchInlineHook<T, Delimiter, Token>, TokenizerParseInlineHook<T, Token, Node> {
17
- constructor(props?: TokenizerProps);
18
- /**
19
- * @override
20
- * @see BaseInlineTokenizer
21
- */
22
- protected _findDelimiter(startIndex: number, endIndex: number, nodePoints: ReadonlyArray<NodePoint>): Delimiter | null;
23
- /**
24
- * @override
25
- * @see TokenizerMatchInlineHook
26
- */
27
- processSingleDelimiter(delimiter: Delimiter): ResultOfProcessSingleDelimiter<T, Token>;
28
- /**
29
- * @override
30
- * @see TokenizerParseInlineHook
31
- */
32
- processToken(token: Token, children: YastNode[] | undefined, nodePoints: ReadonlyArray<NodePoint>): Node;
33
- /**
34
- * Try to eat a delimiter
35
- *
36
- * @param nodePoints
37
- * @param startIndex
38
- * @param endIndex
39
- */
40
- protected tryToEatDelimiter(nodePoints: ReadonlyArray<NodePoint>, startIndex: number, endIndex: number): Delimiter | null;
14
+ export declare class HtmlInlineTokenizer extends BaseInlineTokenizer<T, IDelimiter, IToken, INode, IThis> implements IInlineTokenizer<T, IDelimiter, IToken, INode, IThis> {
15
+ constructor(props?: ITokenizerProps);
16
+ readonly match: IMatchInlineHookCreator<T, IDelimiter, IToken, IThis>;
17
+ readonly parse: IParseInlineHookCreator<T, IToken, INode, IThis>;
41
18
  }
@@ -1,13 +1,13 @@
1
- import type { Html, HtmlType } from '@yozora/ast';
2
- import type { BaseInlineTokenizerProps, PartialYastInlineToken } from '@yozora/core-tokenizer';
3
- import type { HtmlInlineCDataDelimiter, HtmlInlineCDataTokenData } from './util/cdata';
4
- import type { HtmlInlineClosingDelimiter, HtmlInlineClosingTokenData } from './util/closing';
5
- import type { HtmlInlineCommentDelimiter, HtmlInlineCommentTokenData } from './util/comment';
6
- import type { HtmlInlineDeclarationDelimiter, HtmlInlineDeclarationTokenData } from './util/declaration';
7
- import type { HtmlInlineInstructionDelimiter, HtmlInlineInstructionTokenData } from './util/instruction';
8
- import type { HtmlInlineOpenDelimiter, HtmlInlineOpenTokenData as HtmlInlineOpenTokenData } from './util/open';
1
+ import type { HtmlType, IHtml } from '@yozora/ast';
2
+ import type { IBaseInlineTokenizerProps, IPartialYastInlineToken, ITokenizer } from '@yozora/core-tokenizer';
3
+ import type { IHtmlInlineCDataDelimiter, IHtmlInlineCDataTokenData } from './util/cdata';
4
+ import type { IHtmlInlineClosingDelimiter, IHtmlInlineClosingTokenData } from './util/closing';
5
+ import type { IHtmlInlineCommentDelimiter, IHtmlInlineCommentTokenData } from './util/comment';
6
+ import type { IHtmlInlineDeclarationDelimiter, IHtmlInlineDeclarationTokenData } from './util/declaration';
7
+ import type { IHtmlInlineInstructionDelimiter, IHtmlInlineInstructionTokenData } from './util/instruction';
8
+ import type { IHtmlInlineOpenDelimiter, IHtmlInlineOpenTokenData as IHtmlInlineOpenTokenData } from './util/open';
9
9
  export declare type T = HtmlType;
10
- export declare type Node = Html;
10
+ export declare type INode = IHtml;
11
11
  export declare const uniqueName = "@yozora/tokenizer-html-inline";
12
12
  /**
13
13
  * Text between '<' and '>' that looks like an HTML tag is parsed as a raw
@@ -17,6 +17,7 @@ export declare const uniqueName = "@yozora/tokenizer-html-inline";
17
17
  *
18
18
  * @see https://github.github.com/gfm/#raw-html
19
19
  */
20
- export declare type Token = PartialYastInlineToken<T> & (HtmlInlineOpenTokenData | HtmlInlineClosingTokenData | HtmlInlineCommentTokenData | HtmlInlineInstructionTokenData | HtmlInlineDeclarationTokenData | HtmlInlineCDataTokenData);
21
- export declare type Delimiter = HtmlInlineOpenDelimiter | HtmlInlineClosingDelimiter | HtmlInlineCommentDelimiter | HtmlInlineInstructionDelimiter | HtmlInlineDeclarationDelimiter | HtmlInlineCDataDelimiter;
22
- export declare type TokenizerProps = Partial<BaseInlineTokenizerProps>;
20
+ export declare type IToken = IPartialYastInlineToken<T> & (IHtmlInlineOpenTokenData | IHtmlInlineClosingTokenData | IHtmlInlineCommentTokenData | IHtmlInlineInstructionTokenData | IHtmlInlineDeclarationTokenData | IHtmlInlineCDataTokenData);
21
+ export declare type IDelimiter = IHtmlInlineOpenDelimiter | IHtmlInlineClosingDelimiter | IHtmlInlineCommentDelimiter | IHtmlInlineInstructionDelimiter | IHtmlInlineDeclarationDelimiter | IHtmlInlineCDataDelimiter;
22
+ export declare type IThis = ITokenizer;
23
+ export declare type ITokenizerProps = Partial<IBaseInlineTokenizerProps>;
@@ -1,12 +1,12 @@
1
- import type { NodePoint } from '@yozora/character';
2
- import type { YastTokenDelimiter } from '@yozora/core-tokenizer';
3
- export interface HtmlInlineCDataData {
1
+ import type { INodePoint } from '@yozora/character';
2
+ import type { IYastTokenDelimiter } from '@yozora/core-tokenizer';
3
+ export interface IHtmlInlineCDataData {
4
4
  htmlType: 'cdata';
5
5
  }
6
- export interface HtmlInlineCDataTokenData {
6
+ export interface IHtmlInlineCDataTokenData {
7
7
  htmlType: 'cdata';
8
8
  }
9
- export interface HtmlInlineCDataDelimiter extends YastTokenDelimiter, HtmlInlineCDataTokenData {
9
+ export interface IHtmlInlineCDataDelimiter extends IYastTokenDelimiter, IHtmlInlineCDataTokenData {
10
10
  type: 'full';
11
11
  }
12
12
  /**
@@ -18,4 +18,4 @@ export interface HtmlInlineCDataDelimiter extends YastTokenDelimiter, HtmlInline
18
18
  * @param endIndex
19
19
  * @see https://github.github.com/gfm/#cdata-section
20
20
  */
21
- export declare function eatHtmlInlineCDataDelimiter(nodePoints: ReadonlyArray<NodePoint>, startIndex: number, endIndex: number): HtmlInlineCDataDelimiter | null;
21
+ export declare function eatHtmlInlineCDataDelimiter(nodePoints: ReadonlyArray<INodePoint>, startIndex: number, endIndex: number): IHtmlInlineCDataDelimiter | null;
@@ -1,14 +1,14 @@
1
- import type { NodeInterval, NodePoint } from '@yozora/character';
2
- import type { YastTokenDelimiter } from '@yozora/core-tokenizer';
3
- export interface HtmlInlineClosingTagData {
1
+ import type { INodeInterval, INodePoint } from '@yozora/character';
2
+ import type { IYastTokenDelimiter } from '@yozora/core-tokenizer';
3
+ export interface IHtmlInlineClosingTagData {
4
4
  htmlType: 'closing';
5
5
  tagName: string;
6
6
  }
7
- export interface HtmlInlineClosingTokenData {
7
+ export interface IHtmlInlineClosingTokenData {
8
8
  htmlType: 'closing';
9
- tagName: NodeInterval;
9
+ tagName: INodeInterval;
10
10
  }
11
- export interface HtmlInlineClosingDelimiter extends YastTokenDelimiter, HtmlInlineClosingTokenData {
11
+ export interface IHtmlInlineClosingDelimiter extends IYastTokenDelimiter, IHtmlInlineClosingTokenData {
12
12
  type: 'full';
13
13
  }
14
14
  /**
@@ -20,4 +20,4 @@ export interface HtmlInlineClosingDelimiter extends YastTokenDelimiter, HtmlInli
20
20
  * @param endIndex
21
21
  * @see https://github.github.com/gfm/#closing-tag
22
22
  */
23
- export declare function eatHtmlInlineClosingDelimiter(nodePoints: ReadonlyArray<NodePoint>, startIndex: number, endIndex: number): HtmlInlineClosingDelimiter | null;
23
+ export declare function eatHtmlInlineClosingDelimiter(nodePoints: ReadonlyArray<INodePoint>, startIndex: number, endIndex: number): IHtmlInlineClosingDelimiter | null;
@@ -1,12 +1,12 @@
1
- import type { NodePoint } from '@yozora/character';
2
- import type { YastTokenDelimiter } from '@yozora/core-tokenizer';
3
- export interface HtmlInlineCommentData {
1
+ import type { INodePoint } from '@yozora/character';
2
+ import type { IYastTokenDelimiter } from '@yozora/core-tokenizer';
3
+ export interface IHtmlInlineCommentData {
4
4
  htmlType: 'comment';
5
5
  }
6
- export interface HtmlInlineCommentTokenData {
6
+ export interface IHtmlInlineCommentTokenData {
7
7
  htmlType: 'comment';
8
8
  }
9
- export interface HtmlInlineCommentDelimiter extends YastTokenDelimiter, HtmlInlineCommentTokenData {
9
+ export interface IHtmlInlineCommentDelimiter extends IYastTokenDelimiter, IHtmlInlineCommentTokenData {
10
10
  type: 'full';
11
11
  }
12
12
  /**
@@ -18,4 +18,4 @@ export interface HtmlInlineCommentDelimiter extends YastTokenDelimiter, HtmlInli
18
18
  * @param endIndex
19
19
  * @see https://github.github.com/gfm/#html-comment
20
20
  */
21
- export declare function eatHtmlInlineCommentDelimiter(nodePoints: ReadonlyArray<NodePoint>, startIndex: number, endIndex: number): HtmlInlineCommentDelimiter | null;
21
+ export declare function eatHtmlInlineCommentDelimiter(nodePoints: ReadonlyArray<INodePoint>, startIndex: number, endIndex: number): IHtmlInlineCommentDelimiter | null;
@@ -1,13 +1,13 @@
1
- import type { NodeInterval, NodePoint } from '@yozora/character';
2
- import type { YastTokenDelimiter } from '@yozora/core-tokenizer';
3
- export interface HtmlInlineDeclarationData {
1
+ import type { INodeInterval, INodePoint } from '@yozora/character';
2
+ import type { IYastTokenDelimiter } from '@yozora/core-tokenizer';
3
+ export interface IHtmlInlineDeclarationData {
4
4
  htmlType: 'declaration';
5
5
  }
6
- export interface HtmlInlineDeclarationTokenData {
6
+ export interface IHtmlInlineDeclarationTokenData {
7
7
  htmlType: 'declaration';
8
- tagName: NodeInterval;
8
+ tagName: INodeInterval;
9
9
  }
10
- export interface HtmlInlineDeclarationDelimiter extends YastTokenDelimiter, HtmlInlineDeclarationTokenData {
10
+ export interface IHtmlInlineDeclarationDelimiter extends IYastTokenDelimiter, IHtmlInlineDeclarationTokenData {
11
11
  type: 'full';
12
12
  }
13
13
  /**
@@ -20,4 +20,4 @@ export interface HtmlInlineDeclarationDelimiter extends YastTokenDelimiter, Html
20
20
  * @param endIndex
21
21
  * @see https://github.github.com/gfm/#declaration
22
22
  */
23
- export declare function eatHtmlInlineDeclarationDelimiter(nodePoints: ReadonlyArray<NodePoint>, startIndex: number, endIndex: number): HtmlInlineDeclarationDelimiter | null;
23
+ export declare function eatHtmlInlineDeclarationDelimiter(nodePoints: ReadonlyArray<INodePoint>, startIndex: number, endIndex: number): IHtmlInlineDeclarationDelimiter | null;
@@ -1,16 +1,16 @@
1
- import type { NodePoint } from '@yozora/character';
2
- import type { YastTokenDelimiter } from '@yozora/core-tokenizer';
1
+ import type { INodePoint } from '@yozora/character';
2
+ import type { IYastTokenDelimiter } from '@yozora/core-tokenizer';
3
3
  /**
4
4
  *
5
5
  * @see https://github.github.com/gfm/#processing-instruction
6
6
  */
7
- export interface HtmlInlineInstructionData {
7
+ export interface IHtmlInlineInstructionData {
8
8
  htmlType: 'instruction';
9
9
  }
10
- export interface HtmlInlineInstructionTokenData {
10
+ export interface IHtmlInlineInstructionTokenData {
11
11
  htmlType: 'instruction';
12
12
  }
13
- export interface HtmlInlineInstructionDelimiter extends YastTokenDelimiter, HtmlInlineInstructionTokenData {
13
+ export interface IHtmlInlineInstructionDelimiter extends IYastTokenDelimiter, IHtmlInlineInstructionTokenData {
14
14
  type: 'full';
15
15
  }
16
16
  /**
@@ -22,4 +22,4 @@ export interface HtmlInlineInstructionDelimiter extends YastTokenDelimiter, Html
22
22
  * @param endIndex
23
23
  * @see https://github.github.com/gfm/#processing-instruction
24
24
  */
25
- export declare function eatHtmlInlineInstructionDelimiter(nodePoints: ReadonlyArray<NodePoint>, startIndex: number, endIndex: number): HtmlInlineInstructionDelimiter | null;
25
+ export declare function eatHtmlInlineInstructionDelimiter(nodePoints: ReadonlyArray<INodePoint>, startIndex: number, endIndex: number): IHtmlInlineInstructionDelimiter | null;
@@ -1,7 +1,7 @@
1
- import type { NodeInterval, NodePoint } from '@yozora/character';
2
- import type { YastTokenDelimiter } from '@yozora/core-tokenizer';
1
+ import type { INodeInterval, INodePoint } from '@yozora/character';
2
+ import type { IYastTokenDelimiter } from '@yozora/core-tokenizer';
3
3
  import type { RawHTMLAttribute } from '@yozora/tokenizer-html-block';
4
- export interface HtmlInlineOpenTagData {
4
+ export interface IHtmlInlineOpenTagData {
5
5
  htmlType: 'open';
6
6
  /**
7
7
  * HTML tag name.
@@ -19,13 +19,13 @@ export interface HtmlInlineOpenTagData {
19
19
  */
20
20
  selfClosed: boolean;
21
21
  }
22
- export interface HtmlInlineOpenTokenData {
22
+ export interface IHtmlInlineOpenTokenData {
23
23
  htmlType: 'open';
24
- tagName: NodeInterval;
24
+ tagName: INodeInterval;
25
25
  attributes: RawHTMLAttribute[];
26
26
  selfClosed: boolean;
27
27
  }
28
- export interface HtmlInlineOpenDelimiter extends YastTokenDelimiter, HtmlInlineOpenTokenData {
28
+ export interface IHtmlInlineOpenDelimiter extends IYastTokenDelimiter, IHtmlInlineOpenTokenData {
29
29
  type: 'full';
30
30
  }
31
31
  /**
@@ -37,4 +37,4 @@ export interface HtmlInlineOpenDelimiter extends YastTokenDelimiter, HtmlInlineO
37
37
  * @param endIndex
38
38
  * @see https://github.github.com/gfm/#open-tag
39
39
  */
40
- export declare function eatHtmlInlineTokenOpenDelimiter(nodePoints: ReadonlyArray<NodePoint>, startIndex: number, endIndex: number): HtmlInlineOpenDelimiter | null;
40
+ export declare function eatHtmlInlineTokenOpenDelimiter(nodePoints: ReadonlyArray<INodePoint>, startIndex: number, endIndex: number): IHtmlInlineOpenDelimiter | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yozora/tokenizer-html-inline",
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-html-block": "^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-html-block": "^2.0.0-alpha.1"
42
42
  },
43
- "gitHead": "d98d07d7c56dd9f6bb60149b2b0a4be2787e1046"
43
+ "gitHead": "86202e1d2b03ccfc2ab030517d9d314f7aee7666"
44
44
  }