@yozora/tokenizer-html-block 2.1.3 → 2.1.5

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
@@ -2,7 +2,7 @@
2
2
 
3
3
  <header>
4
4
  <h1 align="center">
5
- <a href="https://github.com/yozorajs/yozora/tree/release-2.x.x/tokenizers/html-block#readme">@yozora/tokenizer-html-block</a>
5
+ <a href="https://github.com/yozorajs/yozora/tree/v2.1.5/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/release-2.x.x/tokenizers/html-block#readme
202
+ [homepage]: https://github.com/yozorajs/yozora/tree/v2.1.5/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/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
206
+ [@yozora/ast]: https://github.com/yozorajs/yozora/tree/v2.1.5/packages/ast#readme
207
+ [@yozora/ast-util]: https://github.com/yozorajs/yozora/tree/v2.1.5/packages/ast-util#readme
208
+ [@yozora/character]: https://github.com/yozorajs/yozora/tree/v2.1.5/packages/character#readme
209
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
210
+ [@yozora/core-parser]: https://github.com/yozorajs/yozora/tree/v2.1.5/packages/core-parser#readme
211
+ [@yozora/core-tokenizer]: https://github.com/yozorajs/yozora/tree/v2.1.5/packages/core-tokenizer#readme
212
+ [@yozora/invariant]: https://github.com/yozorajs/yozora/tree/v2.1.5/packages/invariant#readme
213
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
214
+ [@yozora/parser]: https://github.com/yozorajs/yozora/tree/v2.1.5/packages/parser#readme
215
+ [@yozora/parser-gfm]: https://github.com/yozorajs/yozora/tree/v2.1.5/packages/parser-gfm#readme
216
+ [@yozora/parser-gfm-ex]: https://github.com/yozorajs/yozora/tree/v2.1.5/packages/parser-gfm-ex#readme
217
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
218
+ [@yozora/tokenizer-admonition]: https://github.com/yozorajs/yozora/tree/v2.1.5/tokenizers/admonition#readme
219
+ [@yozora/tokenizer-autolink]: https://github.com/yozorajs/yozora/tree/v2.1.5/tokenizers/autolink#readme
220
+ [@yozora/tokenizer-autolink-extension]: https://github.com/yozorajs/yozora/tree/v2.1.5/tokenizers/autolink-extension#readme
221
+ [@yozora/tokenizer-blockquote]: https://github.com/yozorajs/yozora/tree/v2.1.5/tokenizers/blockquote#readme
222
+ [@yozora/tokenizer-break]: https://github.com/yozorajs/yozora/tree/v2.1.5/tokenizers/break#readme
223
+ [@yozora/tokenizer-definition]: https://github.com/yozorajs/yozora/tree/v2.1.5/tokenizers/definition#readme
224
+ [@yozora/tokenizer-delete]: https://github.com/yozorajs/yozora/tree/v2.1.5/tokenizers/delete#readme
225
+ [@yozora/tokenizer-ecma-import]: https://github.com/yozorajs/yozora/tree/v2.1.5/tokenizers/ecma-import#readme
226
+ [@yozora/tokenizer-emphasis]: https://github.com/yozorajs/yozora/tree/v2.1.5/tokenizers/emphasis#readme
227
+ [@yozora/tokenizer-fenced-block]: https://github.com/yozorajs/yozora/tree/v2.1.5/tokenizers/fenced-block#readme
228
+ [@yozora/tokenizer-fenced-code]: https://github.com/yozorajs/yozora/tree/v2.1.5/tokenizers/fenced-code#readme
229
+ [@yozora/tokenizer-footnote]: https://github.com/yozorajs/yozora/tree/v2.1.5/tokenizers/footnote#readme
230
+ [@yozora/tokenizer-footnote-definition]: https://github.com/yozorajs/yozora/tree/v2.1.5/tokenizers/footnote-definition#readme
231
+ [@yozora/tokenizer-footnote-reference]: https://github.com/yozorajs/yozora/tree/v2.1.5/tokenizers/footnote-reference#readme
232
+ [@yozora/tokenizer-heading]: https://github.com/yozorajs/yozora/tree/v2.1.5/tokenizers/heading#readme
233
+ [@yozora/tokenizer-html-block]: https://github.com/yozorajs/yozora/tree/v2.1.5/tokenizers/html-block#readme
234
+ [@yozora/tokenizer-html-inline]: https://github.com/yozorajs/yozora/tree/v2.1.5/tokenizers/html-inline#readme
235
+ [@yozora/tokenizer-image]: https://github.com/yozorajs/yozora/tree/v2.1.5/tokenizers/image#readme
236
+ [@yozora/tokenizer-image-reference]: https://github.com/yozorajs/yozora/tree/v2.1.5/tokenizers/image-reference#readme
237
+ [@yozora/tokenizer-indented-code]: https://github.com/yozorajs/yozora/tree/v2.1.5/tokenizers/indented-code#readme
238
+ [@yozora/tokenizer-inline-code]: https://github.com/yozorajs/yozora/tree/v2.1.5/tokenizers/inline-code#readme
239
+ [@yozora/tokenizer-inline-math]: https://github.com/yozorajs/yozora/tree/v2.1.5/tokenizers/inline-math#readme
240
+ [@yozora/tokenizer-link]: https://github.com/yozorajs/yozora/tree/v2.1.5/tokenizers/link#readme
241
+ [@yozora/tokenizer-link-reference]: https://github.com/yozorajs/yozora/tree/v2.1.5/tokenizers/link-reference#readme
242
+ [@yozora/tokenizer-list]: https://github.com/yozorajs/yozora/tree/v2.1.5/tokenizers/list#readme
243
+ [@yozora/tokenizer-math]: https://github.com/yozorajs/yozora/tree/v2.1.5/tokenizers/math#readme
244
+ [@yozora/tokenizer-paragraph]: https://github.com/yozorajs/yozora/tree/v2.1.5/tokenizers/paragraph#readme
245
+ [@yozora/tokenizer-setext-heading]: https://github.com/yozorajs/yozora/tree/v2.1.5/tokenizers/setext-heading#readme
246
+ [@yozora/tokenizer-table]: https://github.com/yozorajs/yozora/tree/v2.1.5/tokenizers/table#readme
247
+ [@yozora/tokenizer-text]: https://github.com/yozorajs/yozora/tree/v2.1.5/tokenizers/text#readme
248
+ [@yozora/tokenizer-thematic-break]: https://github.com/yozorajs/yozora/tree/v2.1.5/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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yozora/tokenizer-html-block",
3
- "version": "2.1.3",
3
+ "version": "2.1.5",
4
4
  "author": {
5
5
  "name": "guanghechen",
6
6
  "url": "https://github.com/guanghechen/"
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "files": [
29
29
  "lib/",
30
- "src/",
30
+ "!lib/**/*.map",
31
31
  "package.json",
32
32
  "CHANGELOG.md",
33
33
  "LICENSE",
@@ -39,9 +39,9 @@
39
39
  "test": "cross-env TS_NODE_FILES=true NODE_OPTIONS=--experimental-vm-modules jest --config ../../jest.config.mjs --rootDir ."
40
40
  },
41
41
  "dependencies": {
42
- "@yozora/ast": "^2.1.3",
43
- "@yozora/character": "^2.1.3",
44
- "@yozora/core-tokenizer": "^2.1.3"
42
+ "@yozora/ast": "^2.1.5",
43
+ "@yozora/character": "^2.1.5",
44
+ "@yozora/core-tokenizer": "^2.1.5"
45
45
  },
46
- "gitHead": "9abaaff74a12d0bae0f645813241ff947a0d828c"
46
+ "gitHead": "4f753bcf0fd921938464802462dc48c53bbd014d"
47
47
  }
@@ -1,79 +0,0 @@
1
- import type { INodePoint } from '@yozora/character'
2
- import { AsciiCodePoint, calcStringFromNodePoints, isWhitespaceCharacter } from '@yozora/character'
3
- import { eatHTMLTagName } from '../util/eat-html-tagname'
4
-
5
- const includedTags = ['pre', 'script', 'style']
6
-
7
- /**
8
- * Eat block html start condition 1:
9
- *
10
- * line begins with the string `<script`, `<pre`, or
11
- * `<style` (case-insensitive), followed by whitespace, the string `>`,
12
- * or the end of the line.
13
- *
14
- * @param nodePoints
15
- * @param startIndex
16
- * @param endIndex
17
- * @see https://github.github.com/gfm/#start-condition
18
- */
19
- export function eatStartCondition1(
20
- nodePoints: ReadonlyArray<INodePoint>,
21
- startIndex: number,
22
- endIndex: number,
23
- tagName: string,
24
- ): number | null {
25
- if (!includedTags.includes(tagName)) return null
26
- if (startIndex >= endIndex) return endIndex
27
-
28
- const c = nodePoints[startIndex].codePoint
29
- if (isWhitespaceCharacter(c) || c === AsciiCodePoint.CLOSE_ANGLE) {
30
- return startIndex + 1
31
- }
32
- return null
33
- }
34
-
35
- /**
36
- * Eat block html end condition 1:
37
- *
38
- * line contains an end tag `</script>`, `</pre>`,
39
- * or `</style>` (case-insensitive; it need not match the start tag).
40
- *
41
- * @param nodePoints
42
- * @param startIndex
43
- * @param endIndex
44
- * @see https://github.github.com/gfm/#start-condition
45
- */
46
- export function eatEndCondition1(
47
- nodePoints: ReadonlyArray<INodePoint>,
48
- startIndex: number,
49
- endIndex: number,
50
- ): number | null {
51
- for (let i = startIndex; i < endIndex; ++i) {
52
- if (
53
- nodePoints[i].codePoint === AsciiCodePoint.OPEN_ANGLE &&
54
- i + 3 < endIndex &&
55
- nodePoints[i + 1].codePoint === AsciiCodePoint.SLASH
56
- ) {
57
- const tagNameStartIndex = i + 2
58
- const tagNameEndIndex = eatHTMLTagName(nodePoints, tagNameStartIndex, endIndex)
59
- if (
60
- tagNameEndIndex == null ||
61
- tagNameEndIndex >= endIndex ||
62
- nodePoints[tagNameEndIndex].codePoint !== AsciiCodePoint.CLOSE_ANGLE
63
- ) {
64
- i += 1
65
- continue
66
- }
67
-
68
- const rawTagName = calcStringFromNodePoints(
69
- nodePoints,
70
- tagNameStartIndex,
71
- tagNameEndIndex,
72
- true,
73
- )
74
- const tagName = rawTagName.toLowerCase()
75
- if (includedTags.includes(tagName)) return tagNameEndIndex
76
- }
77
- }
78
- return null
79
- }
@@ -1,55 +0,0 @@
1
- import type { INodePoint } from '@yozora/character'
2
- import { AsciiCodePoint } from '@yozora/character'
3
-
4
- /**
5
- * Eat block html start condition 2:
6
- *
7
- * Line begins with the string `<!--`.
8
- *
9
- * @param nodePoints
10
- * @param startIndex
11
- * @param endIndex
12
- * @see https://github.github.com/gfm/#start-condition
13
- */
14
- export function eatStartCondition2(
15
- nodePoints: ReadonlyArray<INodePoint>,
16
- startIndex: number,
17
- endIndex: number,
18
- ): number | null {
19
- const i = startIndex
20
- if (
21
- i + 2 < endIndex &&
22
- nodePoints[i].codePoint === AsciiCodePoint.EXCLAMATION_MARK &&
23
- nodePoints[i + 1].codePoint === AsciiCodePoint.MINUS_SIGN &&
24
- nodePoints[i + 2].codePoint === AsciiCodePoint.MINUS_SIGN
25
- )
26
- return i + 3
27
- return null
28
- }
29
-
30
- /**
31
- * Eat block html end condition 2:
32
- *
33
- * line contains the string `-->`.
34
- *
35
- * @param nodePoints
36
- * @param startIndex
37
- * @param endIndex
38
- * @see https://github.github.com/gfm/#start-condition
39
- */
40
- export function eatEndCondition2(
41
- nodePoints: ReadonlyArray<INodePoint>,
42
- startIndex: number,
43
- endIndex: number,
44
- ): number | null {
45
- for (let i = startIndex; i < endIndex; ++i) {
46
- if (
47
- nodePoints[i].codePoint === AsciiCodePoint.MINUS_SIGN &&
48
- i + 2 < endIndex &&
49
- nodePoints[i + 1].codePoint === AsciiCodePoint.MINUS_SIGN &&
50
- nodePoints[i + 2].codePoint === AsciiCodePoint.CLOSE_ANGLE
51
- )
52
- return i + 3
53
- }
54
- return null
55
- }
@@ -1,48 +0,0 @@
1
- import type { INodePoint } from '@yozora/character'
2
- import { AsciiCodePoint } from '@yozora/character'
3
-
4
- /**
5
- * Eat block html start condition 3:
6
- *
7
- * line begins with the string `<?`.
8
- *
9
- * @param nodePoints
10
- * @param startIndex
11
- * @param endIndex
12
- * @see https://github.github.com/gfm/#start-condition
13
- */
14
- export function eatStartCondition3(
15
- nodePoints: ReadonlyArray<INodePoint>,
16
- startIndex: number,
17
- endIndex: number,
18
- ): number | null {
19
- const i = startIndex
20
- if (i < endIndex && nodePoints[i].codePoint === AsciiCodePoint.QUESTION_MARK) return i + 1
21
- return null
22
- }
23
-
24
- /**
25
- * Eat block html end condition 3:
26
- *
27
- * line contains the string `?>`.
28
- *
29
- * @param nodePoints
30
- * @param startIndex
31
- * @param endIndex
32
- * @see https://github.github.com/gfm/#start-condition
33
- */
34
- export function eatEndCondition3(
35
- nodePoints: ReadonlyArray<INodePoint>,
36
- startIndex: number,
37
- endIndex: number,
38
- ): number | null {
39
- for (let i = startIndex; i < endIndex; ++i) {
40
- if (
41
- nodePoints[i].codePoint === AsciiCodePoint.QUESTION_MARK &&
42
- i + 1 < endIndex &&
43
- nodePoints[i + 1].codePoint === AsciiCodePoint.CLOSE_ANGLE
44
- )
45
- return i + 2
46
- }
47
- return null
48
- }
@@ -1,48 +0,0 @@
1
- import type { INodePoint } from '@yozora/character'
2
- import { AsciiCodePoint, isAsciiUpperLetter } from '@yozora/character'
3
-
4
- /**
5
- * Eat block html start condition 4:
6
- *
7
- * line begins with the string `<!` followed by an uppercase ASCII letter.
8
- *
9
- * @param nodePoints
10
- * @param startIndex
11
- * @param endIndex
12
- * @see https://github.github.com/gfm/#start-condition
13
- */
14
- export function eatStartCondition4(
15
- nodePoints: ReadonlyArray<INodePoint>,
16
- startIndex: number,
17
- endIndex: number,
18
- ): number | null {
19
- const i = startIndex
20
- if (
21
- i + 1 < endIndex &&
22
- nodePoints[i].codePoint === AsciiCodePoint.EXCLAMATION_MARK &&
23
- isAsciiUpperLetter(nodePoints[i + 1].codePoint)
24
- )
25
- return i + 2
26
- return null
27
- }
28
-
29
- /**
30
- * Eat block html end condition 4:
31
- *
32
- * line contains the character >.
33
- *
34
- * @param nodePoints
35
- * @param startIndex
36
- * @param endIndex
37
- * @see https://github.github.com/gfm/#start-condition
38
- */
39
- export function eatEndCondition4(
40
- nodePoints: ReadonlyArray<INodePoint>,
41
- startIndex: number,
42
- endIndex: number,
43
- ): number | null {
44
- for (let i = startIndex; i < endIndex; ++i) {
45
- if (nodePoints[i].codePoint === AsciiCodePoint.CLOSE_ANGLE) return i + 1
46
- }
47
- return null
48
- }
@@ -1,59 +0,0 @@
1
- import type { INodePoint } from '@yozora/character'
2
- import { AsciiCodePoint } from '@yozora/character'
3
-
4
- /**
5
- * Eat block html start condition 5:
6
- *
7
- * line begins with the string `<![CDATA[`.
8
- *
9
- * @param nodePoints
10
- * @param startIndex
11
- * @param endIndex
12
- * @see https://github.github.com/gfm/#start-condition
13
- */
14
- export function eatStartCondition5(
15
- nodePoints: ReadonlyArray<INodePoint>,
16
- startIndex: number,
17
- endIndex: number,
18
- ): number | null {
19
- const i = startIndex
20
- if (
21
- i + 6 < endIndex &&
22
- nodePoints[i].codePoint === AsciiCodePoint.EXCLAMATION_MARK &&
23
- nodePoints[i + 1].codePoint === AsciiCodePoint.OPEN_BRACKET &&
24
- nodePoints[i + 2].codePoint === AsciiCodePoint.UPPERCASE_C &&
25
- nodePoints[i + 3].codePoint === AsciiCodePoint.UPPERCASE_D &&
26
- nodePoints[i + 4].codePoint === AsciiCodePoint.UPPERCASE_A &&
27
- nodePoints[i + 5].codePoint === AsciiCodePoint.UPPERCASE_T &&
28
- nodePoints[i + 6].codePoint === AsciiCodePoint.UPPERCASE_A
29
- )
30
- return i + 7
31
- return null
32
- }
33
-
34
- /**
35
- * Eat block html end condition 5:
36
- *
37
- * line contains the string `]]>`.
38
- *
39
- * @param nodePoints
40
- * @param startIndex
41
- * @param endIndex
42
- * @see https://github.github.com/gfm/#start-condition
43
- */
44
- export function eatEndCondition5(
45
- nodePoints: ReadonlyArray<INodePoint>,
46
- startIndex: number,
47
- endIndex: number,
48
- ): number | null {
49
- for (let i = startIndex; i < endIndex; ++i) {
50
- if (
51
- nodePoints[i].codePoint === AsciiCodePoint.CLOSE_BRACKET &&
52
- i + 2 < endIndex &&
53
- nodePoints[i + 1].codePoint === AsciiCodePoint.CLOSE_BRACKET &&
54
- nodePoints[i + 2].codePoint === AsciiCodePoint.CLOSE_ANGLE
55
- )
56
- return i + 3
57
- }
58
- return null
59
- }
@@ -1,109 +0,0 @@
1
- import type { INodePoint } from '@yozora/character'
2
- import { AsciiCodePoint, isWhitespaceCharacter } from '@yozora/character'
3
-
4
- const includedTags = [
5
- 'address',
6
- 'article',
7
- 'aside',
8
- 'base',
9
- 'basefont',
10
- 'blockquote',
11
- 'body',
12
- 'caption',
13
- 'center',
14
- 'col',
15
- 'colgroup',
16
- 'dd',
17
- 'details',
18
- 'dialog',
19
- 'dir',
20
- 'div',
21
- 'dl',
22
- 'dt',
23
- 'fieldset',
24
- 'figcaption',
25
- 'figure',
26
- 'footer',
27
- 'form',
28
- 'frame',
29
- 'frameset',
30
- 'h1',
31
- 'h2',
32
- 'h3',
33
- 'h4',
34
- 'h5',
35
- 'h6',
36
- 'head',
37
- 'header',
38
- 'hr',
39
- 'html',
40
- 'iframe',
41
- 'legend',
42
- 'li',
43
- 'link',
44
- 'main',
45
- 'menu',
46
- 'menuitem',
47
- 'nav',
48
- 'noframes',
49
- 'ol',
50
- 'optgroup',
51
- 'option',
52
- 'p',
53
- 'param',
54
- 'section',
55
- 'source',
56
- 'summary',
57
- 'table',
58
- 'tbody',
59
- 'td',
60
- 'tfoot',
61
- 'th',
62
- 'thead',
63
- 'title',
64
- 'tr',
65
- 'track',
66
- 'ul',
67
- ]
68
-
69
- /**
70
- * Eat block html start condition 6:
71
- *
72
- * 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
- * @param nodePoints
85
- * @param startIndex
86
- * @param endIndex
87
- * @see https://github.github.com/gfm/#start-condition
88
- */
89
- export function eatStartCondition6(
90
- nodePoints: ReadonlyArray<INodePoint>,
91
- startIndex: number,
92
- endIndex: number,
93
- tagName: string,
94
- ): number | null {
95
- if (!includedTags.includes(tagName)) return null
96
- if (startIndex >= endIndex) return endIndex
97
-
98
- const c = nodePoints[startIndex].codePoint
99
- if (isWhitespaceCharacter(c) || c === AsciiCodePoint.CLOSE_ANGLE) return startIndex + 1
100
-
101
- if (
102
- c === AsciiCodePoint.SLASH &&
103
- startIndex + 1 < endIndex &&
104
- nodePoints[startIndex + 1].codePoint === AsciiCodePoint.CLOSE_ANGLE
105
- )
106
- return startIndex + 2
107
-
108
- return null
109
- }
@@ -1,54 +0,0 @@
1
- import type { INodePoint } from '@yozora/character'
2
- import { AsciiCodePoint, isWhitespaceCharacter } from '@yozora/character'
3
- import { eatOptionalWhitespaces } from '@yozora/core-tokenizer'
4
- import { eatHTMLAttribute } from '../util/eat-html-attribute'
5
-
6
- const excludedTags = ['pre', 'script', 'style']
7
-
8
- /**
9
- * Eat block html start condition 7:
10
- *
11
- * line begins with a complete open tag (with any tag name
12
- * other than `script`, `style`, or `pre`) or a complete closing tag,
13
- * followed only by whitespace or the end of the line
14
- *
15
- * @param nodePoints
16
- * @param startIndex
17
- * @param endIndex
18
- * @see https://github.github.com/gfm/#start-condition
19
- */
20
- export function eatStartCondition7(
21
- nodePoints: ReadonlyArray<INodePoint>,
22
- startIndex: number,
23
- endIndex: number,
24
- tagName: string,
25
- potentialOpenTag: boolean,
26
- ): number | null {
27
- if (excludedTags.includes(tagName) || startIndex >= endIndex) return null
28
-
29
- let i = startIndex
30
-
31
- if (potentialOpenTag) {
32
- // Try to resolve an open tag.
33
- for (; i < endIndex; ) {
34
- const result = eatHTMLAttribute(nodePoints, i, endIndex)
35
- if (result == null) break
36
- i = result.nextIndex
37
- }
38
-
39
- i = eatOptionalWhitespaces(nodePoints, i, endIndex)
40
- if (i >= endIndex) return null
41
-
42
- if (nodePoints[i].codePoint === AsciiCodePoint.SLASH) i += 1
43
- } else {
44
- // Try to resolve a closing tag.
45
- i = eatOptionalWhitespaces(nodePoints, startIndex, endIndex)
46
- }
47
-
48
- if (i >= endIndex || nodePoints[i].codePoint !== AsciiCodePoint.CLOSE_ANGLE) return null
49
-
50
- for (i += 1; i < endIndex; ++i) {
51
- if (!isWhitespaceCharacter(nodePoints[i].codePoint)) return null
52
- }
53
- return endIndex
54
- }
package/src/index.ts DELETED
@@ -1,11 +0,0 @@
1
- export * from './util/eat-html-attribute'
2
- export * from './util/eat-html-tagname'
3
- export { match as htmlBlockMatch } from './match'
4
- export { parse as htmlBlockParse } from './parse'
5
- export { HtmlBlockTokenizer, HtmlBlockTokenizer as default } from './tokenizer'
6
- export { uniqueName as HtmlBlockTokenizerName } from './types'
7
- export type {
8
- IThis as IHtmlBlockHookContext,
9
- IToken as IHtmlBlockToken,
10
- ITokenizerProps as IHtmlBlockTokenizerProps,
11
- } from './types'