@yozora/tokenizer-html-block 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 HtmlBlockTokenizer from '@yozora/tokenizer-html-block'
|
|
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 HtmlBlockTokenizer())
|
|
96
96
|
|
|
97
97
|
// parse source markdown content
|
|
@@ -240,7 +240,6 @@ Name | Type | Required | Default
|
|
|
240
240
|
[@yozora/tokenizer-link]: https://github.com/yozorajs/yozora/tree/main/tokenizers/link#readme
|
|
241
241
|
[@yozora/tokenizer-link-reference]: https://github.com/yozorajs/yozora/tree/main/tokenizers/link-reference#readme
|
|
242
242
|
[@yozora/tokenizer-list]: https://github.com/yozorajs/yozora/tree/main/tokenizers/list#readme
|
|
243
|
-
[@yozora/tokenizer-list-item]: https://github.com/yozorajs/yozora/tree/main/tokenizers/list-item#readme
|
|
244
243
|
[@yozora/tokenizer-math]: https://github.com/yozorajs/yozora/tree/main/tokenizers/math#readme
|
|
245
244
|
[@yozora/tokenizer-paragraph]: https://github.com/yozorajs/yozora/tree/main/tokenizers/paragraph#readme
|
|
246
245
|
[@yozora/tokenizer-setext-heading]: https://github.com/yozorajs/yozora/tree/main/tokenizers/setext-heading#readme
|
|
@@ -300,7 +299,6 @@ Name | Type | Required | Default
|
|
|
300
299
|
[doc-@yozora/tokenizer-definition]: https://yozora.guanghechen.com/docs/package/tokenizer-definition
|
|
301
300
|
[doc-@yozora/tokenizer-link-reference]: https://yozora.guanghechen.com/docs/package/tokenizer-link-reference
|
|
302
301
|
[doc-@yozora/tokenizer-list]: https://yozora.guanghechen.com/docs/package/tokenizer-list
|
|
303
|
-
[doc-@yozora/tokenizer-list-item]: https://yozora.guanghechen.com/docs/package/tokenizer-list-item
|
|
304
302
|
[doc-@yozora/tokenizer-math]: https://yozora.guanghechen.com/docs/package/tokenizer-math
|
|
305
303
|
[doc-@yozora/tokenizer-paragraph]: https://yozora.guanghechen.com/docs/package/tokenizer-paragraph
|
|
306
304
|
[doc-@yozora/tokenizer-setext-heading]: https://yozora.guanghechen.com/docs/package/tokenizer-setext-heading
|
package/lib/cjs/index.js
CHANGED
|
@@ -482,14 +482,15 @@ const match = function () {
|
|
|
482
482
|
|
|
483
483
|
const parse = function () {
|
|
484
484
|
return {
|
|
485
|
-
parse: token => {
|
|
485
|
+
parse: tokens => tokens.map(token => {
|
|
486
486
|
const contents = coreTokenizer.mergeContentLinesFaithfully(token.lines);
|
|
487
487
|
const node = {
|
|
488
488
|
type: 'html',
|
|
489
|
+
position: token.position,
|
|
489
490
|
value: character.calcStringFromNodePoints(contents),
|
|
490
491
|
};
|
|
491
492
|
return node;
|
|
492
|
-
},
|
|
493
|
+
}),
|
|
493
494
|
};
|
|
494
495
|
};
|
|
495
496
|
|
package/lib/esm/index.js
CHANGED
|
@@ -478,14 +478,15 @@ const match = function () {
|
|
|
478
478
|
|
|
479
479
|
const parse = function () {
|
|
480
480
|
return {
|
|
481
|
-
parse: token => {
|
|
481
|
+
parse: tokens => tokens.map(token => {
|
|
482
482
|
const contents = mergeContentLinesFaithfully(token.lines);
|
|
483
483
|
const node = {
|
|
484
484
|
type: 'html',
|
|
485
|
+
position: token.position,
|
|
485
486
|
value: calcStringFromNodePoints(contents),
|
|
486
487
|
};
|
|
487
488
|
return node;
|
|
488
|
-
},
|
|
489
|
+
}),
|
|
489
490
|
};
|
|
490
491
|
};
|
|
491
492
|
|
package/lib/types/index.d.ts
CHANGED
|
@@ -4,4 +4,4 @@ export { match as htmlBlockMatch } from './match';
|
|
|
4
4
|
export { parse as htmlBlockParse } from './parse';
|
|
5
5
|
export { HtmlBlockTokenizer, HtmlBlockTokenizer as default } from './tokenizer';
|
|
6
6
|
export { uniqueName as HtmlBlockTokenizerName } from './types';
|
|
7
|
-
export type {
|
|
7
|
+
export type { IThis as IHtmlBlockHookContext, IToken as IHtmlBlockToken, ITokenizerProps as IHtmlBlockTokenizerProps, } 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
|
* An HTML block is a group of lines that is treated as raw HTML (and will not
|
|
5
5
|
* be escaped in HTML output).
|
|
@@ -7,4 +7,4 @@ import type { IHookContext, IToken, T } from './types';
|
|
|
7
7
|
* @see https://github.com/syntax-tree/mdast#html
|
|
8
8
|
* @see https://github.github.com/gfm/#html-blocks
|
|
9
9
|
*/
|
|
10
|
-
export declare const match: IMatchBlockHookCreator<T, IToken,
|
|
10
|
+
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,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 {
|
|
3
|
+
import type { INode, IThis, IToken, ITokenizerProps, T } from './types';
|
|
4
4
|
/**
|
|
5
5
|
* Lexical Analyzer for HtmlBlock.
|
|
6
6
|
* @see https://github.com/syntax-tree/mdast#html
|
|
7
7
|
* @see https://github.github.com/gfm/#html-blocks
|
|
8
8
|
*/
|
|
9
|
-
export declare class HtmlBlockTokenizer extends BaseBlockTokenizer<T, IToken, INode,
|
|
9
|
+
export declare class HtmlBlockTokenizer extends BaseBlockTokenizer<T, IToken, INode, IThis> implements IBlockTokenizer<T, IToken, INode, IThis> {
|
|
10
10
|
constructor(props?: ITokenizerProps);
|
|
11
|
-
readonly match: IMatchBlockHookCreator<T, IToken,
|
|
12
|
-
readonly parse: IParseBlockHookCreator<T, IToken, INode,
|
|
11
|
+
readonly match: IMatchBlockHookCreator<T, IToken, IThis>;
|
|
12
|
+
readonly parse: IParseBlockHookCreator<T, IToken, INode, IThis>;
|
|
13
13
|
}
|
package/lib/types/types.d.ts
CHANGED
|
@@ -60,5 +60,5 @@ export interface IToken extends IPartialYastBlockToken<T> {
|
|
|
60
60
|
*/
|
|
61
61
|
lines: Array<Readonly<IPhrasingContentLine>>;
|
|
62
62
|
}
|
|
63
|
-
export declare type
|
|
63
|
+
export declare type IThis = ITokenizer;
|
|
64
64
|
export declare type ITokenizerProps = Partial<IBaseBlockTokenizerProps>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yozora/tokenizer-html-block",
|
|
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
|
}
|