@yozora/tokenizer-html-block 2.0.1 → 2.0.2
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 +45 -45
- package/lib/types/index.d.ts +125 -7
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
<header>
|
|
4
4
|
<h1 align="center">
|
|
5
|
-
<a href="https://github.com/yozorajs/yozora/tree/
|
|
5
|
+
<a href="https://github.com/yozorajs/yozora/tree/release-2.x.x/tokenizers/html-block#readme">@yozora/tokenizer-html-block</a>
|
|
6
6
|
</h1>
|
|
7
7
|
<div align="center">
|
|
8
8
|
<a href="https://www.npmjs.com/package/@yozora/tokenizer-html-block">
|
|
@@ -199,53 +199,53 @@ Name | Type | Required | Default
|
|
|
199
199
|
|
|
200
200
|
[live-examples]: https://yozora.guanghechen.com/docs/package/tokenizer-html-block#live-examples
|
|
201
201
|
[docpage]: https://yozora.guanghechen.com/docs/package/tokenizer-html-block
|
|
202
|
-
[homepage]: https://github.com/yozorajs/yozora/tree/
|
|
202
|
+
[homepage]: https://github.com/yozorajs/yozora/tree/release-2.x.x/tokenizers/html-block#readme
|
|
203
203
|
[gfm-spec]: https://github.github.com/gfm
|
|
204
204
|
[mdast-homepage]: https://github.com/syntax-tree/mdast
|
|
205
205
|
|
|
206
|
-
[@yozora/ast]: https://github.com/yozorajs/yozora/tree/
|
|
207
|
-
[@yozora/ast-util]: https://github.com/yozorajs/yozora/tree/
|
|
208
|
-
[@yozora/character]: https://github.com/yozorajs/yozora/tree/
|
|
209
|
-
[@yozora/eslint-config]: https://github.com/yozorajs/yozora/tree/
|
|
210
|
-
[@yozora/core-parser]: https://github.com/yozorajs/yozora/tree/
|
|
211
|
-
[@yozora/core-tokenizer]: https://github.com/yozorajs/yozora/tree/
|
|
212
|
-
[@yozora/invariant]: https://github.com/yozorajs/yozora/tree/
|
|
213
|
-
[@yozora/jest-for-tokenizer]: https://github.com/yozorajs/yozora/tree/
|
|
214
|
-
[@yozora/parser]: https://github.com/yozorajs/yozora/tree/
|
|
215
|
-
[@yozora/parser-gfm]: https://github.com/yozorajs/yozora/tree/
|
|
216
|
-
[@yozora/parser-gfm-ex]: https://github.com/yozorajs/yozora/tree/
|
|
217
|
-
[@yozora/template-tokenizer]: https://github.com/yozorajs/yozora/tree/
|
|
218
|
-
[@yozora/tokenizer-admonition]: https://github.com/yozorajs/yozora/tree/
|
|
219
|
-
[@yozora/tokenizer-autolink]: https://github.com/yozorajs/yozora/tree/
|
|
220
|
-
[@yozora/tokenizer-autolink-extension]: https://github.com/yozorajs/yozora/tree/
|
|
221
|
-
[@yozora/tokenizer-blockquote]: https://github.com/yozorajs/yozora/tree/
|
|
222
|
-
[@yozora/tokenizer-break]: https://github.com/yozorajs/yozora/tree/
|
|
223
|
-
[@yozora/tokenizer-definition]: https://github.com/yozorajs/yozora/tree/
|
|
224
|
-
[@yozora/tokenizer-delete]: https://github.com/yozorajs/yozora/tree/
|
|
225
|
-
[@yozora/tokenizer-ecma-import]: https://github.com/yozorajs/yozora/tree/
|
|
226
|
-
[@yozora/tokenizer-emphasis]: https://github.com/yozorajs/yozora/tree/
|
|
227
|
-
[@yozora/tokenizer-fenced-block]: https://github.com/yozorajs/yozora/tree/
|
|
228
|
-
[@yozora/tokenizer-fenced-code]: https://github.com/yozorajs/yozora/tree/
|
|
229
|
-
[@yozora/tokenizer-footnote]: https://github.com/yozorajs/yozora/tree/
|
|
230
|
-
[@yozora/tokenizer-footnote-definition]: https://github.com/yozorajs/yozora/tree/
|
|
231
|
-
[@yozora/tokenizer-footnote-reference]: https://github.com/yozorajs/yozora/tree/
|
|
232
|
-
[@yozora/tokenizer-heading]: https://github.com/yozorajs/yozora/tree/
|
|
233
|
-
[@yozora/tokenizer-html-block]: https://github.com/yozorajs/yozora/tree/
|
|
234
|
-
[@yozora/tokenizer-html-inline]: https://github.com/yozorajs/yozora/tree/
|
|
235
|
-
[@yozora/tokenizer-image]: https://github.com/yozorajs/yozora/tree/
|
|
236
|
-
[@yozora/tokenizer-image-reference]: https://github.com/yozorajs/yozora/tree/
|
|
237
|
-
[@yozora/tokenizer-indented-code]: https://github.com/yozorajs/yozora/tree/
|
|
238
|
-
[@yozora/tokenizer-inline-code]: https://github.com/yozorajs/yozora/tree/
|
|
239
|
-
[@yozora/tokenizer-inline-math]: https://github.com/yozorajs/yozora/tree/
|
|
240
|
-
[@yozora/tokenizer-link]: https://github.com/yozorajs/yozora/tree/
|
|
241
|
-
[@yozora/tokenizer-link-reference]: https://github.com/yozorajs/yozora/tree/
|
|
242
|
-
[@yozora/tokenizer-list]: https://github.com/yozorajs/yozora/tree/
|
|
243
|
-
[@yozora/tokenizer-math]: https://github.com/yozorajs/yozora/tree/
|
|
244
|
-
[@yozora/tokenizer-paragraph]: https://github.com/yozorajs/yozora/tree/
|
|
245
|
-
[@yozora/tokenizer-setext-heading]: https://github.com/yozorajs/yozora/tree/
|
|
246
|
-
[@yozora/tokenizer-table]: https://github.com/yozorajs/yozora/tree/
|
|
247
|
-
[@yozora/tokenizer-text]: https://github.com/yozorajs/yozora/tree/
|
|
248
|
-
[@yozora/tokenizer-thematic-break]: https://github.com/yozorajs/yozora/tree/
|
|
206
|
+
[@yozora/ast]: https://github.com/yozorajs/yozora/tree/release-2.x.x/packages/ast#readme
|
|
207
|
+
[@yozora/ast-util]: https://github.com/yozorajs/yozora/tree/release-2.x.x/packages/ast-util#readme
|
|
208
|
+
[@yozora/character]: https://github.com/yozorajs/yozora/tree/release-2.x.x/packages/character#readme
|
|
209
|
+
[@yozora/eslint-config]: https://github.com/yozorajs/yozora/tree/release-2.x.x/packages/eslint-config#readme
|
|
210
|
+
[@yozora/core-parser]: https://github.com/yozorajs/yozora/tree/release-2.x.x/packages/core-parser#readme
|
|
211
|
+
[@yozora/core-tokenizer]: https://github.com/yozorajs/yozora/tree/release-2.x.x/packages/core-tokenizer#readme
|
|
212
|
+
[@yozora/invariant]: https://github.com/yozorajs/yozora/tree/release-2.x.x/packages/invariant#readme
|
|
213
|
+
[@yozora/jest-for-tokenizer]: https://github.com/yozorajs/yozora/tree/release-2.x.x/packages/jest-for-tokenizer#readme
|
|
214
|
+
[@yozora/parser]: https://github.com/yozorajs/yozora/tree/release-2.x.x/packages/parser#readme
|
|
215
|
+
[@yozora/parser-gfm]: https://github.com/yozorajs/yozora/tree/release-2.x.x/packages/parser-gfm#readme
|
|
216
|
+
[@yozora/parser-gfm-ex]: https://github.com/yozorajs/yozora/tree/release-2.x.x/packages/parser-gfm-ex#readme
|
|
217
|
+
[@yozora/template-tokenizer]: https://github.com/yozorajs/yozora/tree/release-2.x.x/packages/template-tokenizer#readme
|
|
218
|
+
[@yozora/tokenizer-admonition]: https://github.com/yozorajs/yozora/tree/release-2.x.x/tokenizers/admonition#readme
|
|
219
|
+
[@yozora/tokenizer-autolink]: https://github.com/yozorajs/yozora/tree/release-2.x.x/tokenizers/autolink#readme
|
|
220
|
+
[@yozora/tokenizer-autolink-extension]: https://github.com/yozorajs/yozora/tree/release-2.x.x/tokenizers/autolink-extension#readme
|
|
221
|
+
[@yozora/tokenizer-blockquote]: https://github.com/yozorajs/yozora/tree/release-2.x.x/tokenizers/blockquote#readme
|
|
222
|
+
[@yozora/tokenizer-break]: https://github.com/yozorajs/yozora/tree/release-2.x.x/tokenizers/break#readme
|
|
223
|
+
[@yozora/tokenizer-definition]: https://github.com/yozorajs/yozora/tree/release-2.x.x/tokenizers/definition#readme
|
|
224
|
+
[@yozora/tokenizer-delete]: https://github.com/yozorajs/yozora/tree/release-2.x.x/tokenizers/delete#readme
|
|
225
|
+
[@yozora/tokenizer-ecma-import]: https://github.com/yozorajs/yozora/tree/release-2.x.x/tokenizers/ecma-import#readme
|
|
226
|
+
[@yozora/tokenizer-emphasis]: https://github.com/yozorajs/yozora/tree/release-2.x.x/tokenizers/emphasis#readme
|
|
227
|
+
[@yozora/tokenizer-fenced-block]: https://github.com/yozorajs/yozora/tree/release-2.x.x/tokenizers/fenced-block#readme
|
|
228
|
+
[@yozora/tokenizer-fenced-code]: https://github.com/yozorajs/yozora/tree/release-2.x.x/tokenizers/fenced-code#readme
|
|
229
|
+
[@yozora/tokenizer-footnote]: https://github.com/yozorajs/yozora/tree/release-2.x.x/tokenizers/footnote#readme
|
|
230
|
+
[@yozora/tokenizer-footnote-definition]: https://github.com/yozorajs/yozora/tree/release-2.x.x/tokenizers/footnote-definition#readme
|
|
231
|
+
[@yozora/tokenizer-footnote-reference]: https://github.com/yozorajs/yozora/tree/release-2.x.x/tokenizers/footnote-reference#readme
|
|
232
|
+
[@yozora/tokenizer-heading]: https://github.com/yozorajs/yozora/tree/release-2.x.x/tokenizers/heading#readme
|
|
233
|
+
[@yozora/tokenizer-html-block]: https://github.com/yozorajs/yozora/tree/release-2.x.x/tokenizers/html-block#readme
|
|
234
|
+
[@yozora/tokenizer-html-inline]: https://github.com/yozorajs/yozora/tree/release-2.x.x/tokenizers/html-inline#readme
|
|
235
|
+
[@yozora/tokenizer-image]: https://github.com/yozorajs/yozora/tree/release-2.x.x/tokenizers/image#readme
|
|
236
|
+
[@yozora/tokenizer-image-reference]: https://github.com/yozorajs/yozora/tree/release-2.x.x/tokenizers/image-reference#readme
|
|
237
|
+
[@yozora/tokenizer-indented-code]: https://github.com/yozorajs/yozora/tree/release-2.x.x/tokenizers/indented-code#readme
|
|
238
|
+
[@yozora/tokenizer-inline-code]: https://github.com/yozorajs/yozora/tree/release-2.x.x/tokenizers/inline-code#readme
|
|
239
|
+
[@yozora/tokenizer-inline-math]: https://github.com/yozorajs/yozora/tree/release-2.x.x/tokenizers/inline-math#readme
|
|
240
|
+
[@yozora/tokenizer-link]: https://github.com/yozorajs/yozora/tree/release-2.x.x/tokenizers/link#readme
|
|
241
|
+
[@yozora/tokenizer-link-reference]: https://github.com/yozorajs/yozora/tree/release-2.x.x/tokenizers/link-reference#readme
|
|
242
|
+
[@yozora/tokenizer-list]: https://github.com/yozorajs/yozora/tree/release-2.x.x/tokenizers/list#readme
|
|
243
|
+
[@yozora/tokenizer-math]: https://github.com/yozorajs/yozora/tree/release-2.x.x/tokenizers/math#readme
|
|
244
|
+
[@yozora/tokenizer-paragraph]: https://github.com/yozorajs/yozora/tree/release-2.x.x/tokenizers/paragraph#readme
|
|
245
|
+
[@yozora/tokenizer-setext-heading]: https://github.com/yozorajs/yozora/tree/release-2.x.x/tokenizers/setext-heading#readme
|
|
246
|
+
[@yozora/tokenizer-table]: https://github.com/yozorajs/yozora/tree/release-2.x.x/tokenizers/table#readme
|
|
247
|
+
[@yozora/tokenizer-text]: https://github.com/yozorajs/yozora/tree/release-2.x.x/tokenizers/text#readme
|
|
248
|
+
[@yozora/tokenizer-thematic-break]: https://github.com/yozorajs/yozora/tree/release-2.x.x/tokenizers/thematic-break#readme
|
|
249
249
|
|
|
250
250
|
[@yozora/react-admonition]: https://github.com/yozorajs/yozora-react/tree/main/packages/admonition#readme
|
|
251
251
|
[@yozora/react-blockquote]: https://github.com/yozorajs/yozora-react/tree/main/packages/blockquote#readme
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,7 +1,125 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { INodeInterval, INodePoint } from '@yozora/character';
|
|
2
|
+
import { IPartialYastBlockToken, IPhrasingContentLine, ITokenizer, IBaseBlockTokenizerProps, IMatchBlockHookCreator, IParseBlockHookCreator, BaseBlockTokenizer, IBlockTokenizer } from '@yozora/core-tokenizer';
|
|
3
|
+
import { HtmlType, Html } from '@yozora/ast';
|
|
4
|
+
|
|
5
|
+
interface RawHTMLAttribute {
|
|
6
|
+
/**
|
|
7
|
+
* Attribute name.
|
|
8
|
+
*/
|
|
9
|
+
name: INodeInterval;
|
|
10
|
+
/**
|
|
11
|
+
* Attribute value.
|
|
12
|
+
*/
|
|
13
|
+
value?: INodeInterval;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* An attribute consists of whitespace, an attribute name, and an optional
|
|
17
|
+
* attribute value specification.
|
|
18
|
+
*
|
|
19
|
+
* @param nodePoints
|
|
20
|
+
* @param startIndex
|
|
21
|
+
* @param endIndex
|
|
22
|
+
* @see https://github.github.com/gfm/#attribute
|
|
23
|
+
*/
|
|
24
|
+
declare function eatHTMLAttribute(nodePoints: ReadonlyArray<INodePoint>, startIndex: number, endIndex: number): {
|
|
25
|
+
attribute: RawHTMLAttribute;
|
|
26
|
+
nextIndex: number;
|
|
27
|
+
} | null;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* A tag name consists of an ASCII letter followed by zero or more ASCII
|
|
31
|
+
* letters, digits, or hyphens (-).
|
|
32
|
+
*
|
|
33
|
+
* @param nodePoints
|
|
34
|
+
* @param startIndex
|
|
35
|
+
* @param endIndex
|
|
36
|
+
* @see https://github.github.com/gfm/#tag-name
|
|
37
|
+
*/
|
|
38
|
+
declare function eatHTMLTagName(nodePoints: ReadonlyArray<INodePoint>, startIndex: number, endIndex: number): number | null;
|
|
39
|
+
|
|
40
|
+
declare type T = HtmlType;
|
|
41
|
+
declare type INode = Html;
|
|
42
|
+
declare const uniqueName = "@yozora/tokenizer-html-block";
|
|
43
|
+
declare type HtmlBlockConditionType = 1 | 2 | 3 | 4 | 5 | 6 | 7;
|
|
44
|
+
/**
|
|
45
|
+
* Middle state during the whole match and parse phase.
|
|
46
|
+
*/
|
|
47
|
+
interface IToken extends IPartialYastBlockToken<T> {
|
|
48
|
+
/**
|
|
49
|
+
* Number of conditions defined in GFM:
|
|
50
|
+
*
|
|
51
|
+
* 1. Start condition: line begins with the string `<script`, `<pre`, or
|
|
52
|
+
* `<style` (case-insensitive), followed by whitespace, the string `>`,
|
|
53
|
+
* or the end of the line.
|
|
54
|
+
*
|
|
55
|
+
* End condition: line contains an end tag `</script>`, `</pre>`,
|
|
56
|
+
* or `</style>` (case-insensitive; it need not match the start tag).
|
|
57
|
+
*
|
|
58
|
+
* 2. Start condition: line begins with the string `<!--`.
|
|
59
|
+
* End condition: line contains the string `-->`.
|
|
60
|
+
*
|
|
61
|
+
* 3. Start condition: line begins with the string `<?`.
|
|
62
|
+
* End condition: line contains the string `?>`.
|
|
63
|
+
*
|
|
64
|
+
* 4. Start condition: line begins with the string `<!` followed by an
|
|
65
|
+
* uppercase ASCII letter.
|
|
66
|
+
*
|
|
67
|
+
* End condition: line contains the character >.
|
|
68
|
+
*
|
|
69
|
+
* 5. Start condition: line begins with the string `<![CDATA[`.
|
|
70
|
+
* End condition: line contains the string `]]>`.
|
|
71
|
+
*
|
|
72
|
+
* 6. Start condition: line begins the string `<` or `</` followed by one of
|
|
73
|
+
* the strings (case-insensitive) `address`, `article`, `aside`, `base`,
|
|
74
|
+
* `basefont`, `blockquote`, `body`, `caption`, `center`, `col`, `colgroup`,
|
|
75
|
+
* `dd`, `details`, `dialog`, `dir`, `div`, `dl`, `dt`, `fieldset`,
|
|
76
|
+
* `figcaption`, `figure`, `footer`, `form`, `frame`, `frameset`, `h1`,
|
|
77
|
+
* `h2`, `h3`, `h4`, `h5`, `h6`, `head`, `header`, `hr`, `html`, `iframe`,
|
|
78
|
+
* `legend`, `li`, `link`, `main`, `menu`, `menuitem`, `nav`, `noframes`,
|
|
79
|
+
* `ol`, `optgroup`, `option`, `p`, `param`, `section`, `source`, `summary`,
|
|
80
|
+
* `table`, `tbody`, `td`, `tfoot`, `th`, `thead`, `title`, `tr`, `track`,
|
|
81
|
+
* `ul`, followed by whitespace, the end of the line, the string `>`,
|
|
82
|
+
* or the string `/>`.
|
|
83
|
+
*
|
|
84
|
+
* End condition: line is followed by a blank line.
|
|
85
|
+
*
|
|
86
|
+
* 7. Start condition: line begins with a complete open tag (with any tag name
|
|
87
|
+
* other than `script`, `style`, or `pre`) or a complete closing tag,
|
|
88
|
+
* followed only by whitespace or the end of the line.
|
|
89
|
+
*
|
|
90
|
+
* End condition: line is followed by a blank line.
|
|
91
|
+
*
|
|
92
|
+
* @see https://github.github.com/gfm/#start-condition
|
|
93
|
+
*/
|
|
94
|
+
condition: HtmlBlockConditionType;
|
|
95
|
+
/**
|
|
96
|
+
* Contents
|
|
97
|
+
*/
|
|
98
|
+
lines: Array<Readonly<IPhrasingContentLine>>;
|
|
99
|
+
}
|
|
100
|
+
declare type IThis = ITokenizer;
|
|
101
|
+
declare type ITokenizerProps = Partial<IBaseBlockTokenizerProps>;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* An HTML block is a group of lines that is treated as raw HTML (and will not
|
|
105
|
+
* be escaped in HTML output).
|
|
106
|
+
*
|
|
107
|
+
* @see https://github.com/syntax-tree/mdast#html
|
|
108
|
+
* @see https://github.github.com/gfm/#html-blocks
|
|
109
|
+
*/
|
|
110
|
+
declare const match: IMatchBlockHookCreator<T, IToken, IThis>;
|
|
111
|
+
|
|
112
|
+
declare const parse: IParseBlockHookCreator<T, IToken, INode, IThis>;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Lexical Analyzer for HtmlBlock.
|
|
116
|
+
* @see https://github.com/syntax-tree/mdast#html
|
|
117
|
+
* @see https://github.github.com/gfm/#html-blocks
|
|
118
|
+
*/
|
|
119
|
+
declare class HtmlBlockTokenizer extends BaseBlockTokenizer<T, IToken, INode, IThis> implements IBlockTokenizer<T, IToken, INode, IThis> {
|
|
120
|
+
constructor(props?: ITokenizerProps);
|
|
121
|
+
readonly match: IMatchBlockHookCreator<T, IToken, IThis>;
|
|
122
|
+
readonly parse: IParseBlockHookCreator<T, IToken, INode, IThis>;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export { HtmlBlockTokenizer, uniqueName as HtmlBlockTokenizerName, IThis as IHtmlBlockHookContext, IToken as IHtmlBlockToken, ITokenizerProps as IHtmlBlockTokenizerProps, RawHTMLAttribute, HtmlBlockTokenizer as default, eatHTMLAttribute, eatHTMLTagName, match as htmlBlockMatch, parse as htmlBlockParse };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yozora/tokenizer-html-block",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "guanghechen",
|
|
6
6
|
"url": "https://github.com/guanghechen/"
|
|
@@ -10,14 +10,14 @@
|
|
|
10
10
|
"url": "https://github.com/yozorajs/yozora.git",
|
|
11
11
|
"directory": "tokenizers/html-block"
|
|
12
12
|
},
|
|
13
|
-
"homepage": "https://
|
|
13
|
+
"homepage": "https://github.com/yozorajs/yozora/tree/release-2.x.x/tokenizers/html-block",
|
|
14
14
|
"main": "lib/cjs/index.js",
|
|
15
15
|
"module": "lib/esm/index.js",
|
|
16
16
|
"types": "lib/types/index.d.ts",
|
|
17
17
|
"source": "src/index.ts",
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"engines": {
|
|
20
|
-
"node": ">=
|
|
20
|
+
"node": ">= 16.0.0"
|
|
21
21
|
},
|
|
22
22
|
"files": [
|
|
23
23
|
"lib/",
|
|
@@ -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.
|
|
39
|
-
"@yozora/character": "^2.0.
|
|
40
|
-
"@yozora/core-tokenizer": "^2.0.
|
|
38
|
+
"@yozora/ast": "^2.0.2",
|
|
39
|
+
"@yozora/character": "^2.0.2",
|
|
40
|
+
"@yozora/core-tokenizer": "^2.0.2"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "6911295e9eacfa29563fe93494704190e50625fd"
|
|
43
43
|
}
|