@yozora/tokenizer-html-block 2.0.2-alpha.0 → 2.0.3
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/LICENSE +1 -1
- package/README.md +45 -45
- package/lib/types/index.d.ts +125 -7
- package/package.json +8 -8
- package/lib/types/conditions/c1.d.ts +0 -26
- package/lib/types/conditions/c2.d.ts +0 -23
- package/lib/types/conditions/c3.d.ts +0 -23
- package/lib/types/conditions/c4.d.ts +0 -23
- package/lib/types/conditions/c5.d.ts +0 -23
- package/lib/types/conditions/c6.d.ts +0 -22
- package/lib/types/conditions/c7.d.ts +0 -14
- package/lib/types/match.d.ts +0 -10
- package/lib/types/parse.d.ts +0 -3
- package/lib/types/tokenizer.d.ts +0 -13
- package/lib/types/types.d.ts +0 -64
- package/lib/types/util/eat-html-attribute.d.ts +0 -24
- package/lib/types/util/eat-html-tagname.d.ts +0 -11
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2020-
|
|
3
|
+
Copyright (c) 2020-2022 guanghechen (me.guanghechen@gmail.com)
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
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.3",
|
|
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/",
|
|
@@ -30,14 +30,14 @@
|
|
|
30
30
|
],
|
|
31
31
|
"scripts": {
|
|
32
32
|
"build": "cross-env NODE_ENV=production rollup -c ../../rollup.config.js",
|
|
33
|
-
"prebuild": "rimraf lib/
|
|
33
|
+
"prebuild": "rimraf lib/",
|
|
34
34
|
"prepublishOnly": "cross-env ROLLUP_SHOULD_SOURCEMAP=false yarn build",
|
|
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.3",
|
|
39
|
+
"@yozora/character": "^2.0.3",
|
|
40
|
+
"@yozora/core-tokenizer": "^2.0.3"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "8cc8f95cfebc8d752bc3272cdd24965f540c130b"
|
|
43
43
|
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { INodePoint } from '@yozora/character';
|
|
2
|
-
/**
|
|
3
|
-
* Eat block html start condition 1:
|
|
4
|
-
*
|
|
5
|
-
* line begins with the string `<script`, `<pre`, or
|
|
6
|
-
* `<style` (case-insensitive), followed by whitespace, the string `>`,
|
|
7
|
-
* or the end of the line.
|
|
8
|
-
*
|
|
9
|
-
* @param nodePoints
|
|
10
|
-
* @param startIndex
|
|
11
|
-
* @param endIndex
|
|
12
|
-
* @see https://github.github.com/gfm/#start-condition
|
|
13
|
-
*/
|
|
14
|
-
export declare function eatStartCondition1(nodePoints: ReadonlyArray<INodePoint>, startIndex: number, endIndex: number, tagName: string): number | null;
|
|
15
|
-
/**
|
|
16
|
-
* Eat block html end condition 1:
|
|
17
|
-
*
|
|
18
|
-
* line contains an end tag `</script>`, `</pre>`,
|
|
19
|
-
* or `</style>` (case-insensitive; it need not match the start tag).
|
|
20
|
-
*
|
|
21
|
-
* @param nodePoints
|
|
22
|
-
* @param startIndex
|
|
23
|
-
* @param endIndex
|
|
24
|
-
* @see https://github.github.com/gfm/#start-condition
|
|
25
|
-
*/
|
|
26
|
-
export declare function eatEndCondition1(nodePoints: ReadonlyArray<INodePoint>, startIndex: number, endIndex: number): number | null;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { INodePoint } from '@yozora/character';
|
|
2
|
-
/**
|
|
3
|
-
* Eat block html start condition 2:
|
|
4
|
-
*
|
|
5
|
-
* Line begins with the string `<!--`.
|
|
6
|
-
*
|
|
7
|
-
* @param nodePoints
|
|
8
|
-
* @param startIndex
|
|
9
|
-
* @param endIndex
|
|
10
|
-
* @see https://github.github.com/gfm/#start-condition
|
|
11
|
-
*/
|
|
12
|
-
export declare function eatStartCondition2(nodePoints: ReadonlyArray<INodePoint>, startIndex: number, endIndex: number): number | null;
|
|
13
|
-
/**
|
|
14
|
-
* Eat block html end condition 2:
|
|
15
|
-
*
|
|
16
|
-
* line contains the string `-->`.
|
|
17
|
-
*
|
|
18
|
-
* @param nodePoints
|
|
19
|
-
* @param startIndex
|
|
20
|
-
* @param endIndex
|
|
21
|
-
* @see https://github.github.com/gfm/#start-condition
|
|
22
|
-
*/
|
|
23
|
-
export declare function eatEndCondition2(nodePoints: ReadonlyArray<INodePoint>, startIndex: number, endIndex: number): number | null;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { INodePoint } from '@yozora/character';
|
|
2
|
-
/**
|
|
3
|
-
* Eat block html start condition 3:
|
|
4
|
-
*
|
|
5
|
-
* line begins with the string `<?`.
|
|
6
|
-
*
|
|
7
|
-
* @param nodePoints
|
|
8
|
-
* @param startIndex
|
|
9
|
-
* @param endIndex
|
|
10
|
-
* @see https://github.github.com/gfm/#start-condition
|
|
11
|
-
*/
|
|
12
|
-
export declare function eatStartCondition3(nodePoints: ReadonlyArray<INodePoint>, startIndex: number, endIndex: number): number | null;
|
|
13
|
-
/**
|
|
14
|
-
* Eat block html end condition 3:
|
|
15
|
-
*
|
|
16
|
-
* line contains the string `?>`.
|
|
17
|
-
*
|
|
18
|
-
* @param nodePoints
|
|
19
|
-
* @param startIndex
|
|
20
|
-
* @param endIndex
|
|
21
|
-
* @see https://github.github.com/gfm/#start-condition
|
|
22
|
-
*/
|
|
23
|
-
export declare function eatEndCondition3(nodePoints: ReadonlyArray<INodePoint>, startIndex: number, endIndex: number): number | null;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { INodePoint } from '@yozora/character';
|
|
2
|
-
/**
|
|
3
|
-
* Eat block html start condition 4:
|
|
4
|
-
*
|
|
5
|
-
* line begins with the string `<!` followed by an uppercase ASCII letter.
|
|
6
|
-
*
|
|
7
|
-
* @param nodePoints
|
|
8
|
-
* @param startIndex
|
|
9
|
-
* @param endIndex
|
|
10
|
-
* @see https://github.github.com/gfm/#start-condition
|
|
11
|
-
*/
|
|
12
|
-
export declare function eatStartCondition4(nodePoints: ReadonlyArray<INodePoint>, startIndex: number, endIndex: number): number | null;
|
|
13
|
-
/**
|
|
14
|
-
* Eat block html end condition 4:
|
|
15
|
-
*
|
|
16
|
-
* line contains the character >.
|
|
17
|
-
*
|
|
18
|
-
* @param nodePoints
|
|
19
|
-
* @param startIndex
|
|
20
|
-
* @param endIndex
|
|
21
|
-
* @see https://github.github.com/gfm/#start-condition
|
|
22
|
-
*/
|
|
23
|
-
export declare function eatEndCondition4(nodePoints: ReadonlyArray<INodePoint>, startIndex: number, endIndex: number): number | null;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { INodePoint } from '@yozora/character';
|
|
2
|
-
/**
|
|
3
|
-
* Eat block html start condition 5:
|
|
4
|
-
*
|
|
5
|
-
* line begins with the string `<![CDATA[`.
|
|
6
|
-
*
|
|
7
|
-
* @param nodePoints
|
|
8
|
-
* @param startIndex
|
|
9
|
-
* @param endIndex
|
|
10
|
-
* @see https://github.github.com/gfm/#start-condition
|
|
11
|
-
*/
|
|
12
|
-
export declare function eatStartCondition5(nodePoints: ReadonlyArray<INodePoint>, startIndex: number, endIndex: number): number | null;
|
|
13
|
-
/**
|
|
14
|
-
* Eat block html end condition 5:
|
|
15
|
-
*
|
|
16
|
-
* line contains the string `]]>`.
|
|
17
|
-
*
|
|
18
|
-
* @param nodePoints
|
|
19
|
-
* @param startIndex
|
|
20
|
-
* @param endIndex
|
|
21
|
-
* @see https://github.github.com/gfm/#start-condition
|
|
22
|
-
*/
|
|
23
|
-
export declare function eatEndCondition5(nodePoints: ReadonlyArray<INodePoint>, startIndex: number, endIndex: number): number | null;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { INodePoint } from '@yozora/character';
|
|
2
|
-
/**
|
|
3
|
-
* Eat block html start condition 6:
|
|
4
|
-
*
|
|
5
|
-
* line begins the string `<` or `</` followed by one of
|
|
6
|
-
* the strings (case-insensitive) `address`, `article`, `aside`, `base`,
|
|
7
|
-
* `basefont`, `blockquote`, `body`, `caption`, `center`, `col`, `colgroup`,
|
|
8
|
-
* `dd`, `details`, `dialog`, `dir`, `div`, `dl`, `dt`, `fieldset`,
|
|
9
|
-
* `figcaption`, `figure`, `footer`, `form`, `frame`, `frameset`, `h1`,
|
|
10
|
-
* `h2`, `h3`, `h4`, `h5`, `h6`, `head`, `header`, `hr`, `html`, `iframe`,
|
|
11
|
-
* `legend`, `li`, `link`, `main`, `menu`, `menuitem`, `nav`, `noframes`,
|
|
12
|
-
* `ol`, `optgroup`, `option`, `p`, `param`, `section`, `source`, `summary`,
|
|
13
|
-
* `table`, `tbody`, `td`, `tfoot`, `th`, `thead`, `title`, `tr`, `track`,
|
|
14
|
-
* `ul`, followed by whitespace, the end of the line, the string `>`,
|
|
15
|
-
* or the string `/>`.
|
|
16
|
-
*
|
|
17
|
-
* @param nodePoints
|
|
18
|
-
* @param startIndex
|
|
19
|
-
* @param endIndex
|
|
20
|
-
* @see https://github.github.com/gfm/#start-condition
|
|
21
|
-
*/
|
|
22
|
-
export declare function eatStartCondition6(nodePoints: ReadonlyArray<INodePoint>, startIndex: number, endIndex: number, tagName: string): number | null;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { INodePoint } from '@yozora/character';
|
|
2
|
-
/**
|
|
3
|
-
* Eat block html start condition 7:
|
|
4
|
-
*
|
|
5
|
-
* line begins with a complete open tag (with any tag name
|
|
6
|
-
* other than `script`, `style`, or `pre`) or a complete closing tag,
|
|
7
|
-
* followed only by whitespace or the end of the line
|
|
8
|
-
*
|
|
9
|
-
* @param nodePoints
|
|
10
|
-
* @param startIndex
|
|
11
|
-
* @param endIndex
|
|
12
|
-
* @see https://github.github.com/gfm/#start-condition
|
|
13
|
-
*/
|
|
14
|
-
export declare function eatStartCondition7(nodePoints: ReadonlyArray<INodePoint>, startIndex: number, endIndex: number, tagName: string, potentialOpenTag: boolean): number | null;
|
package/lib/types/match.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { IMatchBlockHookCreator } from '@yozora/core-tokenizer';
|
|
2
|
-
import type { IThis, IToken, T } from './types';
|
|
3
|
-
/**
|
|
4
|
-
* An HTML block is a group of lines that is treated as raw HTML (and will not
|
|
5
|
-
* be escaped in HTML output).
|
|
6
|
-
*
|
|
7
|
-
* @see https://github.com/syntax-tree/mdast#html
|
|
8
|
-
* @see https://github.github.com/gfm/#html-blocks
|
|
9
|
-
*/
|
|
10
|
-
export declare const match: IMatchBlockHookCreator<T, IToken, IThis>;
|
package/lib/types/parse.d.ts
DELETED
package/lib/types/tokenizer.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { IBlockTokenizer, IMatchBlockHookCreator, IParseBlockHookCreator } from '@yozora/core-tokenizer';
|
|
2
|
-
import { BaseBlockTokenizer } from '@yozora/core-tokenizer';
|
|
3
|
-
import type { INode, IThis, IToken, ITokenizerProps, T } from './types';
|
|
4
|
-
/**
|
|
5
|
-
* Lexical Analyzer for HtmlBlock.
|
|
6
|
-
* @see https://github.com/syntax-tree/mdast#html
|
|
7
|
-
* @see https://github.github.com/gfm/#html-blocks
|
|
8
|
-
*/
|
|
9
|
-
export declare class HtmlBlockTokenizer extends BaseBlockTokenizer<T, IToken, INode, IThis> implements IBlockTokenizer<T, IToken, INode, IThis> {
|
|
10
|
-
constructor(props?: ITokenizerProps);
|
|
11
|
-
readonly match: IMatchBlockHookCreator<T, IToken, IThis>;
|
|
12
|
-
readonly parse: IParseBlockHookCreator<T, IToken, INode, IThis>;
|
|
13
|
-
}
|
package/lib/types/types.d.ts
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import type { Html, HtmlType } from '@yozora/ast';
|
|
2
|
-
import type { IBaseBlockTokenizerProps, IPartialYastBlockToken, IPhrasingContentLine, ITokenizer } from '@yozora/core-tokenizer';
|
|
3
|
-
export declare type T = HtmlType;
|
|
4
|
-
export declare type INode = Html;
|
|
5
|
-
export declare const uniqueName = "@yozora/tokenizer-html-block";
|
|
6
|
-
export declare type HtmlBlockConditionType = 1 | 2 | 3 | 4 | 5 | 6 | 7;
|
|
7
|
-
/**
|
|
8
|
-
* Middle state during the whole match and parse phase.
|
|
9
|
-
*/
|
|
10
|
-
export interface IToken extends IPartialYastBlockToken<T> {
|
|
11
|
-
/**
|
|
12
|
-
* Number of conditions defined in GFM:
|
|
13
|
-
*
|
|
14
|
-
* 1. Start condition: line begins with the string `<script`, `<pre`, or
|
|
15
|
-
* `<style` (case-insensitive), followed by whitespace, the string `>`,
|
|
16
|
-
* or the end of the line.
|
|
17
|
-
*
|
|
18
|
-
* End condition: line contains an end tag `</script>`, `</pre>`,
|
|
19
|
-
* or `</style>` (case-insensitive; it need not match the start tag).
|
|
20
|
-
*
|
|
21
|
-
* 2. Start condition: line begins with the string `<!--`.
|
|
22
|
-
* End condition: line contains the string `-->`.
|
|
23
|
-
*
|
|
24
|
-
* 3. Start condition: line begins with the string `<?`.
|
|
25
|
-
* End condition: line contains the string `?>`.
|
|
26
|
-
*
|
|
27
|
-
* 4. Start condition: line begins with the string `<!` followed by an
|
|
28
|
-
* uppercase ASCII letter.
|
|
29
|
-
*
|
|
30
|
-
* End condition: line contains the character >.
|
|
31
|
-
*
|
|
32
|
-
* 5. Start condition: line begins with the string `<![CDATA[`.
|
|
33
|
-
* End condition: line contains the string `]]>`.
|
|
34
|
-
*
|
|
35
|
-
* 6. Start condition: line begins the string `<` or `</` followed by one of
|
|
36
|
-
* the strings (case-insensitive) `address`, `article`, `aside`, `base`,
|
|
37
|
-
* `basefont`, `blockquote`, `body`, `caption`, `center`, `col`, `colgroup`,
|
|
38
|
-
* `dd`, `details`, `dialog`, `dir`, `div`, `dl`, `dt`, `fieldset`,
|
|
39
|
-
* `figcaption`, `figure`, `footer`, `form`, `frame`, `frameset`, `h1`,
|
|
40
|
-
* `h2`, `h3`, `h4`, `h5`, `h6`, `head`, `header`, `hr`, `html`, `iframe`,
|
|
41
|
-
* `legend`, `li`, `link`, `main`, `menu`, `menuitem`, `nav`, `noframes`,
|
|
42
|
-
* `ol`, `optgroup`, `option`, `p`, `param`, `section`, `source`, `summary`,
|
|
43
|
-
* `table`, `tbody`, `td`, `tfoot`, `th`, `thead`, `title`, `tr`, `track`,
|
|
44
|
-
* `ul`, followed by whitespace, the end of the line, the string `>`,
|
|
45
|
-
* or the string `/>`.
|
|
46
|
-
*
|
|
47
|
-
* End condition: line is followed by a blank line.
|
|
48
|
-
*
|
|
49
|
-
* 7. Start condition: line begins with a complete open tag (with any tag name
|
|
50
|
-
* other than `script`, `style`, or `pre`) or a complete closing tag,
|
|
51
|
-
* followed only by whitespace or the end of the line.
|
|
52
|
-
*
|
|
53
|
-
* End condition: line is followed by a blank line.
|
|
54
|
-
*
|
|
55
|
-
* @see https://github.github.com/gfm/#start-condition
|
|
56
|
-
*/
|
|
57
|
-
condition: HtmlBlockConditionType;
|
|
58
|
-
/**
|
|
59
|
-
* Contents
|
|
60
|
-
*/
|
|
61
|
-
lines: Array<Readonly<IPhrasingContentLine>>;
|
|
62
|
-
}
|
|
63
|
-
export declare type IThis = ITokenizer;
|
|
64
|
-
export declare type ITokenizerProps = Partial<IBaseBlockTokenizerProps>;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { INodeInterval, INodePoint } from '@yozora/character';
|
|
2
|
-
export interface RawHTMLAttribute {
|
|
3
|
-
/**
|
|
4
|
-
* Attribute name.
|
|
5
|
-
*/
|
|
6
|
-
name: INodeInterval;
|
|
7
|
-
/**
|
|
8
|
-
* Attribute value.
|
|
9
|
-
*/
|
|
10
|
-
value?: INodeInterval;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* An attribute consists of whitespace, an attribute name, and an optional
|
|
14
|
-
* attribute value specification.
|
|
15
|
-
*
|
|
16
|
-
* @param nodePoints
|
|
17
|
-
* @param startIndex
|
|
18
|
-
* @param endIndex
|
|
19
|
-
* @see https://github.github.com/gfm/#attribute
|
|
20
|
-
*/
|
|
21
|
-
export declare function eatHTMLAttribute(nodePoints: ReadonlyArray<INodePoint>, startIndex: number, endIndex: number): {
|
|
22
|
-
attribute: RawHTMLAttribute;
|
|
23
|
-
nextIndex: number;
|
|
24
|
-
} | null;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { INodePoint } from '@yozora/character';
|
|
2
|
-
/**
|
|
3
|
-
* A tag name consists of an ASCII letter followed by zero or more ASCII
|
|
4
|
-
* letters, digits, or hyphens (-).
|
|
5
|
-
*
|
|
6
|
-
* @param nodePoints
|
|
7
|
-
* @param startIndex
|
|
8
|
-
* @param endIndex
|
|
9
|
-
* @see https://github.github.com/gfm/#tag-name
|
|
10
|
-
*/
|
|
11
|
-
export declare function eatHTMLTagName(nodePoints: ReadonlyArray<INodePoint>, startIndex: number, endIndex: number): number | null;
|