-
-
Notifications
You must be signed in to change notification settings - Fork 515
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(parser/html): misc minor parsing fixes (#4852)
- Loading branch information
Showing
10 changed files
with
314 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
crates/biome_html_parser/tests/html_specs/error/element/child-no-tag-name.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<div><</div> |
119 changes: 119 additions & 0 deletions
119
crates/biome_html_parser/tests/html_specs/error/element/child-no-tag-name.html.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
--- | ||
source: crates/biome_html_parser/tests/spec_test.rs | ||
expression: snapshot | ||
--- | ||
## Input | ||
|
||
```html | ||
<div><</div> | ||
``` | ||
|
||
|
||
## AST | ||
|
||
``` | ||
HtmlRoot { | ||
bom_token: missing (optional), | ||
directive: missing (optional), | ||
html: HtmlElementList [ | ||
HtmlElement { | ||
opening_element: HtmlOpeningElement { | ||
l_angle_token: L_ANGLE@0..1 "<" [] [], | ||
name: HtmlName { | ||
value_token: HTML_LITERAL@1..4 "div" [] [], | ||
}, | ||
attributes: HtmlAttributeList [], | ||
r_angle_token: R_ANGLE@4..5 ">" [] [], | ||
}, | ||
children: HtmlElementList [ | ||
HtmlElement { | ||
opening_element: HtmlOpeningElement { | ||
l_angle_token: L_ANGLE@5..6 "<" [] [], | ||
name: missing (required), | ||
attributes: HtmlAttributeList [], | ||
r_angle_token: missing (required), | ||
}, | ||
children: HtmlElementList [], | ||
closing_element: HtmlClosingElement { | ||
l_angle_token: L_ANGLE@6..7 "<" [] [], | ||
slash_token: SLASH@7..8 "/" [] [], | ||
name: HtmlName { | ||
value_token: HTML_LITERAL@8..11 "div" [] [], | ||
}, | ||
r_angle_token: R_ANGLE@11..12 ">" [] [], | ||
}, | ||
}, | ||
], | ||
closing_element: missing (required), | ||
}, | ||
], | ||
eof_token: EOF@12..13 "" [Newline("\n")] [], | ||
} | ||
``` | ||
|
||
## CST | ||
|
||
``` | ||
0: [email protected] | ||
0: (empty) | ||
1: (empty) | ||
2: [email protected] | ||
0: [email protected] | ||
0: [email protected] | ||
0: [email protected] "<" [] [] | ||
1: [email protected] | ||
0: [email protected] "div" [] [] | ||
2: [email protected] | ||
3: [email protected] ">" [] [] | ||
1: [email protected] | ||
0: [email protected] | ||
0: [email protected] | ||
0: [email protected] "<" [] [] | ||
1: (empty) | ||
2: [email protected] | ||
3: (empty) | ||
1: [email protected] | ||
2: [email protected] | ||
0: [email protected] "<" [] [] | ||
1: [email protected] "/" [] [] | ||
2: [email protected] | ||
0: [email protected] "div" [] [] | ||
3: [email protected] ">" [] [] | ||
2: (empty) | ||
3: [email protected] "" [Newline("\n")] [] | ||
``` | ||
|
||
## Diagnostics | ||
|
||
``` | ||
child-no-tag-name.html:1:7 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
× Expected an element name but instead found '<'. | ||
> 1 │ <div><</div> | ||
│ ^ | ||
2 │ | ||
i Expected an element name here. | ||
> 1 │ <div><</div> | ||
│ ^ | ||
2 │ | ||
child-no-tag-name.html:2:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
× Expected a closing tag but instead found the end of the file. | ||
1 │ <div><</div> | ||
> 2 │ | ||
│ | ||
i Expected a closing tag here. | ||
1 │ <div><</div> | ||
> 2 │ | ||
│ | ||
``` |
1 change: 1 addition & 0 deletions
1
crates/biome_html_parser/tests/html_specs/error/element/missing-close-tag-2.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<div> |
74 changes: 74 additions & 0 deletions
74
crates/biome_html_parser/tests/html_specs/error/element/missing-close-tag-2.html.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
--- | ||
source: crates/biome_html_parser/tests/spec_test.rs | ||
expression: snapshot | ||
--- | ||
## Input | ||
|
||
```html | ||
<div> | ||
``` | ||
## AST | ||
``` | ||
HtmlRoot { | ||
bom_token: missing (optional), | ||
directive: missing (optional), | ||
html: HtmlElementList [ | ||
HtmlElement { | ||
opening_element: HtmlOpeningElement { | ||
l_angle_token: L_ANGLE@0..1 "<" [] [], | ||
name: HtmlName { | ||
value_token: HTML_LITERAL@1..4 "div" [] [], | ||
}, | ||
attributes: HtmlAttributeList [], | ||
r_angle_token: R_ANGLE@4..5 ">" [] [], | ||
}, | ||
children: HtmlElementList [], | ||
closing_element: missing (required), | ||
}, | ||
], | ||
eof_token: EOF@5..6 "" [Newline("\n")] [], | ||
} | ||
``` | ||
## CST | ||
``` | ||
0: [email protected] | ||
0: (empty) | ||
1: (empty) | ||
2: [email protected] | ||
0: [email protected] | ||
0: [email protected] | ||
0: [email protected] "<" [] [] | ||
1: [email protected] | ||
0: [email protected] "div" [] [] | ||
2: [email protected] | ||
3: [email protected] ">" [] [] | ||
1: [email protected] | ||
2: (empty) | ||
3: [email protected] "" [Newline("\n")] [] | ||
``` | ||
## Diagnostics | ||
``` | ||
missing-close-tag-2.html:2:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
× Expected a closing tag but instead found the end of the file. | ||
1 │ <div> | ||
> 2 │ | ||
│ | ||
i Expected a closing tag here. | ||
1 │ <div> | ||
> 2 │ | ||
│ | ||
``` |
1 change: 1 addition & 0 deletions
1
crates/biome_html_parser/tests/html_specs/error/element/solo-no-tag-name.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
< |
Oops, something went wrong.