@yozora/tokenizer-footnote-definition 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
@@ -83,14 +83,14 @@ so you can use `YozoraParser` directly.
83
83
  registered in *YastParser* as a plugin-in before it can be used.
84
84
 
85
85
  ```typescript {4,9}
86
- import { DefaultYastParser } from '@yozora/core-parser'
86
+ import { DefaultParser } from '@yozora/core-parser'
87
87
  import ParagraphTokenizer from '@yozora/tokenizer-paragraph'
88
88
  import TextTokenizer from '@yozora/tokenizer-text'
89
89
  import FootnoteDefinitionTokenizer from '@yozora/tokenizer-footnote-definition'
90
90
 
91
- const parser = new DefaultYastParser()
92
- .useBlockFallbackTokenizer(new ParagraphTokenizer())
93
- .useInlineFallbackTokenizer(new TextTokenizer())
91
+ const parser = new DefaultParser()
92
+ .useFallbackTokenizer(new ParagraphTokenizer())
93
+ .useFallbackTokenizer(new TextTokenizer())
94
94
  .useTokenizer(new FootnoteDefinitionTokenizer())
95
95
 
96
96
  // parse source markdown content
@@ -278,7 +278,6 @@ Name | Type | Required | Default
278
278
  [@yozora/tokenizer-link]: https://github.com/yozorajs/yozora/tree/main/tokenizers/link#readme
279
279
  [@yozora/tokenizer-link-reference]: https://github.com/yozorajs/yozora/tree/main/tokenizers/link-reference#readme
280
280
  [@yozora/tokenizer-list]: https://github.com/yozorajs/yozora/tree/main/tokenizers/list#readme
281
- [@yozora/tokenizer-list-item]: https://github.com/yozorajs/yozora/tree/main/tokenizers/list-item#readme
282
281
  [@yozora/tokenizer-math]: https://github.com/yozorajs/yozora/tree/main/tokenizers/math#readme
283
282
  [@yozora/tokenizer-paragraph]: https://github.com/yozorajs/yozora/tree/main/tokenizers/paragraph#readme
284
283
  [@yozora/tokenizer-setext-heading]: https://github.com/yozorajs/yozora/tree/main/tokenizers/setext-heading#readme
@@ -338,7 +337,6 @@ Name | Type | Required | Default
338
337
  [doc-@yozora/tokenizer-definition]: https://yozora.guanghechen.com/docs/package/tokenizer-definition
339
338
  [doc-@yozora/tokenizer-link-reference]: https://yozora.guanghechen.com/docs/package/tokenizer-link-reference
340
339
  [doc-@yozora/tokenizer-list]: https://yozora.guanghechen.com/docs/package/tokenizer-list
341
- [doc-@yozora/tokenizer-list-item]: https://yozora.guanghechen.com/docs/package/tokenizer-list-item
342
340
  [doc-@yozora/tokenizer-math]: https://yozora.guanghechen.com/docs/package/tokenizer-math
343
341
  [doc-@yozora/tokenizer-paragraph]: https://yozora.guanghechen.com/docs/package/tokenizer-paragraph
344
342
  [doc-@yozora/tokenizer-setext-heading]: https://yozora.guanghechen.com/docs/package/tokenizer-setext-heading
package/lib/cjs/index.js CHANGED
@@ -57,8 +57,8 @@ const match = function (api) {
57
57
  const token = {
58
58
  nodeType: ast.FootnoteDefinitionType,
59
59
  position: {
60
- start: coreTokenizer.calcStartYastNodePoint(nodePoints, startIndex),
61
- end: coreTokenizer.calcEndYastNodePoint(nodePoints, nextIndex),
60
+ start: coreTokenizer.calcStartPoint(nodePoints, startIndex),
61
+ end: coreTokenizer.calcEndPoint(nodePoints, nextIndex),
62
62
  },
63
63
  label: {
64
64
  nodePoints,
@@ -91,19 +91,28 @@ const match = function (api) {
91
91
  }
92
92
  };
93
93
 
94
- const parse = function () {
94
+ const parse = function (api) {
95
95
  return {
96
- parse: (token, children) => {
96
+ parse: tokens => tokens.map(token => {
97
97
  const label = token._label;
98
98
  const identifier = token._identifier;
99
- const node = {
100
- type: ast.FootnoteDefinitionType,
101
- identifier,
102
- label,
103
- children,
104
- };
99
+ const children = api.parseBlockTokens(token.children);
100
+ const node = api.shouldReservePosition
101
+ ? {
102
+ type: ast.FootnoteDefinitionType,
103
+ position: token.position,
104
+ identifier,
105
+ label,
106
+ children,
107
+ }
108
+ : {
109
+ type: ast.FootnoteDefinitionType,
110
+ identifier,
111
+ label,
112
+ children,
113
+ };
105
114
  return node;
106
- },
115
+ }),
107
116
  };
108
117
  };
109
118
 
package/lib/esm/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { AsciiCodePoint, isWhitespaceCharacter, VirtualCodePoint, calcStringFromNodePoints } from '@yozora/character';
2
2
  import { FootnoteDefinitionType } from '@yozora/ast';
3
- import { calcStartYastNodePoint, calcEndYastNodePoint, resolveLabelToIdentifier, BaseBlockTokenizer, TokenizerPriority } from '@yozora/core-tokenizer';
3
+ import { calcStartPoint, calcEndPoint, resolveLabelToIdentifier, BaseBlockTokenizer, TokenizerPriority } from '@yozora/core-tokenizer';
4
4
 
5
5
  function eatFootnoteLabel(nodePoints, firstNonWhitespaceIndex, endIndex) {
6
6
  let i = firstNonWhitespaceIndex;
@@ -53,8 +53,8 @@ const match = function (api) {
53
53
  const token = {
54
54
  nodeType: FootnoteDefinitionType,
55
55
  position: {
56
- start: calcStartYastNodePoint(nodePoints, startIndex),
57
- end: calcEndYastNodePoint(nodePoints, nextIndex),
56
+ start: calcStartPoint(nodePoints, startIndex),
57
+ end: calcEndPoint(nodePoints, nextIndex),
58
58
  },
59
59
  label: {
60
60
  nodePoints,
@@ -87,19 +87,28 @@ const match = function (api) {
87
87
  }
88
88
  };
89
89
 
90
- const parse = function () {
90
+ const parse = function (api) {
91
91
  return {
92
- parse: (token, children) => {
92
+ parse: tokens => tokens.map(token => {
93
93
  const label = token._label;
94
94
  const identifier = token._identifier;
95
- const node = {
96
- type: FootnoteDefinitionType,
97
- identifier,
98
- label,
99
- children,
100
- };
95
+ const children = api.parseBlockTokens(token.children);
96
+ const node = api.shouldReservePosition
97
+ ? {
98
+ type: FootnoteDefinitionType,
99
+ position: token.position,
100
+ identifier,
101
+ label,
102
+ children,
103
+ }
104
+ : {
105
+ type: FootnoteDefinitionType,
106
+ identifier,
107
+ label,
108
+ children,
109
+ };
101
110
  return node;
102
- },
111
+ }),
103
112
  };
104
113
  };
105
114
 
@@ -3,4 +3,4 @@ export { match as footnoteDefinitionMatch } from './match';
3
3
  export { parse as footnoteDefinitionParse } from './parse';
4
4
  export { FootnoteDefinitionTokenizer, FootnoteDefinitionTokenizer as default } from './tokenizer';
5
5
  export { uniqueName as FootnoteDefinitionTokenizerName } from './types';
6
- export type { IHookContext as IFootnoteDefinitionHookContext, IToken as IFootnoteDefinitionToken, ITokenizerProps as IFootnoteDefinitionTokenizerProps, } from './types';
6
+ export type { IThis as IFootnoteDefinitionHookContext, IToken as IFootnoteDefinitionToken, ITokenizerProps as IFootnoteDefinitionTokenizerProps, } 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 footnote reference definition consists of a footnote label, indented up
5
5
  * to three spaces, followed by a colon (:), optional whitespace (including up
@@ -19,4 +19,4 @@ import type { IHookContext, IToken, T } from './types';
19
19
  * @see https://github.com/remarkjs/remark-footnotes
20
20
  * @see https://www.markdownguide.org/extended-syntax/#footnotes
21
21
  */
22
- export declare const match: IMatchBlockHookCreator<T, IToken, IHookContext>;
22
+ 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,6 +1,6 @@
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 FootnoteDefinition.
6
6
  * @see https://github.github.com/gfm/#link-label
@@ -9,9 +9,9 @@ import type { IHookContext, INode, IToken, ITokenizerProps, T } from './types';
9
9
  * @see https://github.com/remarkjs/remark-footnotes
10
10
  * @see https://www.markdownguide.org/extended-syntax/#footnotes
11
11
  */
12
- export declare class FootnoteDefinitionTokenizer extends BaseBlockTokenizer<T, IToken, INode, IHookContext> implements IBlockTokenizer<T, IToken, INode, IHookContext> {
12
+ export declare class FootnoteDefinitionTokenizer extends BaseBlockTokenizer<T, IToken, INode, IThis> implements IBlockTokenizer<T, IToken, INode, IThis> {
13
13
  constructor(props?: ITokenizerProps);
14
14
  readonly indent = 4;
15
- readonly match: IMatchBlockHookCreator<T, IToken, IHookContext>;
16
- readonly parse: IParseBlockHookCreator<T, IToken, INode, IHookContext>;
15
+ readonly match: IMatchBlockHookCreator<T, IToken, IThis>;
16
+ readonly parse: IParseBlockHookCreator<T, IToken, INode, IThis>;
17
17
  }
@@ -1,8 +1,8 @@
1
- import type { FootnoteDefinitionType, IFootnoteDefinition } from '@yozora/ast';
1
+ import type { FootnoteDefinition, FootnoteDefinitionType } from '@yozora/ast';
2
2
  import type { INodeInterval, INodePoint } from '@yozora/character';
3
3
  import type { IBaseBlockTokenizerProps, IPartialYastBlockToken, ITokenizer, IYastBlockToken } from '@yozora/core-tokenizer';
4
4
  export declare type T = FootnoteDefinitionType;
5
- export declare type INode = IFootnoteDefinition;
5
+ export declare type INode = FootnoteDefinition;
6
6
  export declare const uniqueName = "@yozora/tokenizer-footnote-definition";
7
7
  export interface IToken extends IPartialYastBlockToken<T> {
8
8
  /**
@@ -24,7 +24,7 @@ export interface IToken extends IPartialYastBlockToken<T> {
24
24
  */
25
25
  _identifier?: string;
26
26
  }
27
- export interface IHookContext extends ITokenizer {
27
+ export interface IThis extends ITokenizer {
28
28
  indent: number;
29
29
  }
30
30
  export declare type ITokenizerProps = Partial<IBaseBlockTokenizerProps>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yozora/tokenizer-footnote-definition",
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
  }