@yozora/tokenizer-blockquote 2.0.0-alpha.0 → 2.0.0

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 BlockquoteTokenizer from '@yozora/tokenizer-blockquote'
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 BlockquoteTokenizer())
96
96
 
97
97
  // parse source markdown content
@@ -233,7 +233,6 @@ Name | Type | Required | Default
233
233
  [@yozora/tokenizer-link]: https://github.com/yozorajs/yozora/tree/main/tokenizers/link#readme
234
234
  [@yozora/tokenizer-link-reference]: https://github.com/yozorajs/yozora/tree/main/tokenizers/link-reference#readme
235
235
  [@yozora/tokenizer-list]: https://github.com/yozorajs/yozora/tree/main/tokenizers/list#readme
236
- [@yozora/tokenizer-list-item]: https://github.com/yozorajs/yozora/tree/main/tokenizers/list-item#readme
237
236
  [@yozora/tokenizer-math]: https://github.com/yozorajs/yozora/tree/main/tokenizers/math#readme
238
237
  [@yozora/tokenizer-paragraph]: https://github.com/yozorajs/yozora/tree/main/tokenizers/paragraph#readme
239
238
  [@yozora/tokenizer-setext-heading]: https://github.com/yozorajs/yozora/tree/main/tokenizers/setext-heading#readme
@@ -293,7 +292,6 @@ Name | Type | Required | Default
293
292
  [doc-@yozora/tokenizer-definition]: https://yozora.guanghechen.com/docs/package/tokenizer-definition
294
293
  [doc-@yozora/tokenizer-link-reference]: https://yozora.guanghechen.com/docs/package/tokenizer-link-reference
295
294
  [doc-@yozora/tokenizer-list]: https://yozora.guanghechen.com/docs/package/tokenizer-list
296
- [doc-@yozora/tokenizer-list-item]: https://yozora.guanghechen.com/docs/package/tokenizer-list-item
297
295
  [doc-@yozora/tokenizer-math]: https://yozora.guanghechen.com/docs/package/tokenizer-math
298
296
  [doc-@yozora/tokenizer-paragraph]: https://yozora.guanghechen.com/docs/package/tokenizer-paragraph
299
297
  [doc-@yozora/tokenizer-setext-heading]: https://yozora.guanghechen.com/docs/package/tokenizer-setext-heading
package/lib/cjs/index.js CHANGED
@@ -30,8 +30,8 @@ const match = function () {
30
30
  const token = {
31
31
  nodeType: ast.BlockquoteType,
32
32
  position: {
33
- start: coreTokenizer.calcStartYastNodePoint(nodePoints, startIndex),
34
- end: coreTokenizer.calcEndYastNodePoint(nodePoints, nextIndex - 1),
33
+ start: coreTokenizer.calcStartPoint(nodePoints, startIndex),
34
+ end: coreTokenizer.calcEndPoint(nodePoints, nextIndex - 1),
35
35
  },
36
36
  children: [],
37
37
  };
@@ -65,12 +65,15 @@ const match = function () {
65
65
  }
66
66
  };
67
67
 
68
- const parse = function () {
68
+ const parse = function (api) {
69
69
  return {
70
- parse: (_token, children) => {
71
- const node = { type: ast.BlockquoteType, children };
70
+ parse: tokens => tokens.map(token => {
71
+ const children = api.parseBlockTokens(token.children);
72
+ const node = api.shouldReservePosition
73
+ ? { type: ast.BlockquoteType, position: token.position, children }
74
+ : { type: ast.BlockquoteType, children };
72
75
  return node;
73
- },
76
+ }),
74
77
  };
75
78
  };
76
79
 
package/lib/esm/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { BlockquoteType } from '@yozora/ast';
2
2
  import { AsciiCodePoint, isSpaceCharacter, VirtualCodePoint } from '@yozora/character';
3
- import { calcStartYastNodePoint, calcEndYastNodePoint, BaseBlockTokenizer, TokenizerPriority } from '@yozora/core-tokenizer';
3
+ import { calcStartPoint, calcEndPoint, BaseBlockTokenizer, TokenizerPriority } from '@yozora/core-tokenizer';
4
4
 
5
5
  const match = function () {
6
6
  return {
@@ -26,8 +26,8 @@ const match = function () {
26
26
  const token = {
27
27
  nodeType: BlockquoteType,
28
28
  position: {
29
- start: calcStartYastNodePoint(nodePoints, startIndex),
30
- end: calcEndYastNodePoint(nodePoints, nextIndex - 1),
29
+ start: calcStartPoint(nodePoints, startIndex),
30
+ end: calcEndPoint(nodePoints, nextIndex - 1),
31
31
  },
32
32
  children: [],
33
33
  };
@@ -61,12 +61,15 @@ const match = function () {
61
61
  }
62
62
  };
63
63
 
64
- const parse = function () {
64
+ const parse = function (api) {
65
65
  return {
66
- parse: (_token, children) => {
67
- const node = { type: BlockquoteType, children };
66
+ parse: tokens => tokens.map(token => {
67
+ const children = api.parseBlockTokens(token.children);
68
+ const node = api.shouldReservePosition
69
+ ? { type: BlockquoteType, position: token.position, children }
70
+ : { type: BlockquoteType, children };
68
71
  return node;
69
- },
72
+ }),
70
73
  };
71
74
  };
72
75
 
@@ -2,4 +2,4 @@ export { match as blockquoteMatch } from './match';
2
2
  export { parse as blockquoteParse } from './parse';
3
3
  export { BlockquoteTokenizer, BlockquoteTokenizer as default } from './tokenizer';
4
4
  export { uniqueName as BlockquoteTokenizerName } from './types';
5
- export type { IHookContext as IBlockquoteHookContext, IToken as IBlockquoteToken, ITokenizerProps as IBlockquoteTokenizerProps, } from './types';
5
+ export type { IThis as IBlockquoteHookContext, IToken as IBlockquoteToken, ITokenizerProps as IBlockquoteTokenizerProps, } from './types';
@@ -1,5 +1,5 @@
1
1
  import type { IMatchBlockHookCreator } from '@yozora/core-tokenizer';
2
- import type { IHookContext, IToken, T } from './types';
2
+ import type { IThis, IToken, T } from './types';
3
3
  /**
4
4
  * A block quote marker consists of 0-3 spaces of initial indent, plus
5
5
  * (a) the character > together with a following space, or
@@ -24,4 +24,4 @@ import type { IHookContext, IToken, T } from './types';
24
24
  * @see https://github.com/syntax-tree/mdast#blockquote
25
25
  * @see https://github.github.com/gfm/#block-quotes
26
26
  */
27
- export declare const match: IMatchBlockHookCreator<T, IToken, IHookContext>;
27
+ export declare const match: IMatchBlockHookCreator<T, IToken, IThis>;
@@ -1,3 +1,3 @@
1
1
  import type { IParseBlockHookCreator } from '@yozora/core-tokenizer';
2
- import type { IHookContext, INode, IToken, T } from './types';
3
- export declare const parse: IParseBlockHookCreator<T, IToken, INode, IHookContext>;
2
+ import type { INode, IThis, IToken, T } from './types';
3
+ export declare const parse: IParseBlockHookCreator<T, IToken, INode, IThis>;
@@ -1,13 +1,13 @@
1
1
  import type { IBlockTokenizer, IMatchBlockHookCreator, IParseBlockHookCreator } from '@yozora/core-tokenizer';
2
2
  import { BaseBlockTokenizer } from '@yozora/core-tokenizer';
3
- import type { IHookContext, INode, IToken, ITokenizerProps, T } from './types';
3
+ import type { INode, IThis, IToken, ITokenizerProps, T } from './types';
4
4
  /**
5
5
  * Lexical Analyzer for Blockquote.
6
6
  * @see https://github.com/syntax-tree/mdast#blockquote
7
7
  * @see https://github.github.com/gfm/#block-quotes
8
8
  */
9
- export declare class BlockquoteTokenizer extends BaseBlockTokenizer<T, IToken, INode, IHookContext> implements IBlockTokenizer<T, IToken, INode, IHookContext> {
9
+ export declare class BlockquoteTokenizer extends BaseBlockTokenizer<T, IToken, INode, IThis> implements IBlockTokenizer<T, IToken, INode, IThis> {
10
10
  constructor(props?: ITokenizerProps);
11
- readonly match: IMatchBlockHookCreator<T, IToken, IHookContext>;
12
- readonly parse: IParseBlockHookCreator<T, IToken, INode, IHookContext>;
11
+ readonly match: IMatchBlockHookCreator<T, IToken, IThis>;
12
+ readonly parse: IParseBlockHookCreator<T, IToken, INode, IThis>;
13
13
  }
@@ -1,7 +1,7 @@
1
- import type { BlockquoteType, IBlockquote } from '@yozora/ast';
1
+ import type { Blockquote, BlockquoteType } from '@yozora/ast';
2
2
  import type { IBaseBlockTokenizerProps, IPartialYastBlockToken, ITokenizer, IYastBlockToken } from '@yozora/core-tokenizer';
3
3
  export declare type T = BlockquoteType;
4
- export declare type INode = IBlockquote;
4
+ export declare type INode = Blockquote;
5
5
  export declare const uniqueName = "@yozora/tokenizer-blockquote";
6
6
  export interface IToken extends IPartialYastBlockToken<T> {
7
7
  /**
@@ -9,5 +9,5 @@ export interface IToken extends IPartialYastBlockToken<T> {
9
9
  */
10
10
  children: IYastBlockToken[];
11
11
  }
12
- export declare type IHookContext = ITokenizer;
12
+ export declare type IThis = ITokenizer;
13
13
  export declare type ITokenizerProps = Partial<IBaseBlockTokenizerProps>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yozora/tokenizer-blockquote",
3
- "version": "2.0.0-alpha.0",
3
+ "version": "2.0.0",
4
4
  "author": {
5
5
  "name": "guanghechen",
6
6
  "url": "https://github.com/guanghechen/"
@@ -35,9 +35,9 @@
35
35
  "test": "cross-env TS_NODE_FILES=true jest --config ../../jest.config.js --rootDir ."
36
36
  },
37
37
  "dependencies": {
38
- "@yozora/ast": "^2.0.0-alpha.0",
39
- "@yozora/character": "^2.0.0-alpha.0",
40
- "@yozora/core-tokenizer": "^2.0.0-alpha.0"
38
+ "@yozora/ast": "^2.0.0",
39
+ "@yozora/character": "^2.0.0",
40
+ "@yozora/core-tokenizer": "^2.0.0"
41
41
  },
42
- "gitHead": "0171501339c49ffd02ed16a63447fa20a47a29a7"
42
+ "gitHead": "65e99d1709fdd1c918465dce6b1e91de96bdab5e"
43
43
  }