@yozora/tokenizer-definition 2.0.0-alpha.0 → 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 +4 -6
- package/lib/cjs/index.js +3 -2
- package/lib/esm/index.js +3 -2
- package/lib/types/index.d.ts +1 -1
- package/lib/types/match.d.ts +2 -2
- package/lib/types/parse.d.ts +2 -2
- package/lib/types/tokenizer.d.ts +4 -4
- package/lib/types/types.d.ts +1 -1
- package/package.json +5 -5
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 DefinitionTokenizer from '@yozora/tokenizer-definition'
|
|
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 DefinitionTokenizer())
|
|
96
96
|
|
|
97
97
|
// parse source markdown content
|
|
@@ -242,7 +242,6 @@ Name | Type | Required | Default
|
|
|
242
242
|
[@yozora/tokenizer-link]: https://github.com/yozorajs/yozora/tree/main/tokenizers/link#readme
|
|
243
243
|
[@yozora/tokenizer-link-reference]: https://github.com/yozorajs/yozora/tree/main/tokenizers/link-reference#readme
|
|
244
244
|
[@yozora/tokenizer-list]: https://github.com/yozorajs/yozora/tree/main/tokenizers/list#readme
|
|
245
|
-
[@yozora/tokenizer-list-item]: https://github.com/yozorajs/yozora/tree/main/tokenizers/list-item#readme
|
|
246
245
|
[@yozora/tokenizer-math]: https://github.com/yozorajs/yozora/tree/main/tokenizers/math#readme
|
|
247
246
|
[@yozora/tokenizer-paragraph]: https://github.com/yozorajs/yozora/tree/main/tokenizers/paragraph#readme
|
|
248
247
|
[@yozora/tokenizer-setext-heading]: https://github.com/yozorajs/yozora/tree/main/tokenizers/setext-heading#readme
|
|
@@ -302,7 +301,6 @@ Name | Type | Required | Default
|
|
|
302
301
|
[doc-@yozora/tokenizer-definition]: https://yozora.guanghechen.com/docs/package/tokenizer-definition
|
|
303
302
|
[doc-@yozora/tokenizer-link-reference]: https://yozora.guanghechen.com/docs/package/tokenizer-link-reference
|
|
304
303
|
[doc-@yozora/tokenizer-list]: https://yozora.guanghechen.com/docs/package/tokenizer-list
|
|
305
|
-
[doc-@yozora/tokenizer-list-item]: https://yozora.guanghechen.com/docs/package/tokenizer-list-item
|
|
306
304
|
[doc-@yozora/tokenizer-math]: https://yozora.guanghechen.com/docs/package/tokenizer-math
|
|
307
305
|
[doc-@yozora/tokenizer-paragraph]: https://yozora.guanghechen.com/docs/package/tokenizer-paragraph
|
|
308
306
|
[doc-@yozora/tokenizer-setext-heading]: https://yozora.guanghechen.com/docs/package/tokenizer-setext-heading
|
package/lib/cjs/index.js
CHANGED
|
@@ -392,7 +392,7 @@ const match = function (api) {
|
|
|
392
392
|
|
|
393
393
|
const parse = function () {
|
|
394
394
|
return {
|
|
395
|
-
parse: token => {
|
|
395
|
+
parse: tokens => tokens.map(token => {
|
|
396
396
|
const label = token._label;
|
|
397
397
|
const identifier = token._identifier;
|
|
398
398
|
const destinationPoints = token.destination.nodePoints;
|
|
@@ -405,13 +405,14 @@ const parse = function () {
|
|
|
405
405
|
: character.calcEscapedStringFromNodePoints(token.title.nodePoints, 1, token.title.nodePoints.length - 1);
|
|
406
406
|
const node = {
|
|
407
407
|
type: ast.DefinitionType,
|
|
408
|
+
position: token.position,
|
|
408
409
|
identifier,
|
|
409
410
|
label,
|
|
410
411
|
url,
|
|
411
412
|
title,
|
|
412
413
|
};
|
|
413
414
|
return node;
|
|
414
|
-
},
|
|
415
|
+
}),
|
|
415
416
|
};
|
|
416
417
|
};
|
|
417
418
|
|
package/lib/esm/index.js
CHANGED
|
@@ -388,7 +388,7 @@ const match = function (api) {
|
|
|
388
388
|
|
|
389
389
|
const parse = function () {
|
|
390
390
|
return {
|
|
391
|
-
parse: token => {
|
|
391
|
+
parse: tokens => tokens.map(token => {
|
|
392
392
|
const label = token._label;
|
|
393
393
|
const identifier = token._identifier;
|
|
394
394
|
const destinationPoints = token.destination.nodePoints;
|
|
@@ -401,13 +401,14 @@ const parse = function () {
|
|
|
401
401
|
: calcEscapedStringFromNodePoints(token.title.nodePoints, 1, token.title.nodePoints.length - 1);
|
|
402
402
|
const node = {
|
|
403
403
|
type: DefinitionType,
|
|
404
|
+
position: token.position,
|
|
404
405
|
identifier,
|
|
405
406
|
label,
|
|
406
407
|
url,
|
|
407
408
|
title,
|
|
408
409
|
};
|
|
409
410
|
return node;
|
|
410
|
-
},
|
|
411
|
+
}),
|
|
411
412
|
};
|
|
412
413
|
};
|
|
413
414
|
|
package/lib/types/index.d.ts
CHANGED
|
@@ -5,4 +5,4 @@ export { match as definitionMatch } from './match';
|
|
|
5
5
|
export { parse as definitionParse } from './parse';
|
|
6
6
|
export { DefinitionTokenizer, DefinitionTokenizer as default } from './tokenizer';
|
|
7
7
|
export { uniqueName as DefinitionTokenizerName } from './types';
|
|
8
|
-
export type {
|
|
8
|
+
export type { IThis as IDefinitionHookContext, IToken as IDefinitionToken, ITokenizerProps as IDefinitionTokenizerProps, } from './types';
|
package/lib/types/match.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IMatchBlockHookCreator } from '@yozora/core-tokenizer';
|
|
2
|
-
import type {
|
|
2
|
+
import type { IThis, IToken, T } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* A link reference definition consists of a link label, indented up to three
|
|
5
5
|
* spaces, followed by a colon (:), optional whitespace (including up to one
|
|
@@ -15,4 +15,4 @@ import type { IHookContext, IToken, T } from './types';
|
|
|
15
15
|
*
|
|
16
16
|
* @see https://github.github.com/gfm/#link-reference-definition
|
|
17
17
|
*/
|
|
18
|
-
export declare const match: IMatchBlockHookCreator<T, IToken,
|
|
18
|
+
export declare const match: IMatchBlockHookCreator<T, IToken, IThis>;
|
package/lib/types/parse.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { IParseBlockHookCreator } from '@yozora/core-tokenizer';
|
|
2
|
-
import type {
|
|
3
|
-
export declare const parse: IParseBlockHookCreator<T, IToken, INode,
|
|
2
|
+
import type { INode, IThis, IToken, T } from './types';
|
|
3
|
+
export declare const parse: IParseBlockHookCreator<T, IToken, INode, IThis>;
|
package/lib/types/tokenizer.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { IBlockTokenizer, IMatchBlockHookCreator, IParseBlockHookCreator } from '@yozora/core-tokenizer';
|
|
2
2
|
import { BaseBlockTokenizer } from '@yozora/core-tokenizer';
|
|
3
|
-
import type {
|
|
3
|
+
import type { INode, IThis, IToken, ITokenizerProps, T } from './types';
|
|
4
4
|
/**
|
|
5
5
|
* Lexical Analyzer for Definition.
|
|
6
6
|
* @see https://github.github.com/gfm/#link-reference-definition
|
|
7
7
|
*/
|
|
8
|
-
export declare class DefinitionTokenizer extends BaseBlockTokenizer<T, IToken, INode,
|
|
8
|
+
export declare class DefinitionTokenizer extends BaseBlockTokenizer<T, IToken, INode, IThis> implements IBlockTokenizer<T, IToken, INode, IThis> {
|
|
9
9
|
constructor(props?: ITokenizerProps);
|
|
10
|
-
readonly match: IMatchBlockHookCreator<T, IToken,
|
|
11
|
-
readonly parse: IParseBlockHookCreator<T, IToken, INode,
|
|
10
|
+
readonly match: IMatchBlockHookCreator<T, IToken, IThis>;
|
|
11
|
+
readonly parse: IParseBlockHookCreator<T, IToken, INode, IThis>;
|
|
12
12
|
}
|
package/lib/types/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yozora/tokenizer-definition",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.1",
|
|
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.
|
|
39
|
-
"@yozora/character": "^2.0.0-alpha.
|
|
40
|
-
"@yozora/core-tokenizer": "^2.0.0-alpha.
|
|
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
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "86202e1d2b03ccfc2ab030517d9d314f7aee7666"
|
|
43
43
|
}
|