-
-
Notifications
You must be signed in to change notification settings - Fork 475
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(parser/html): lex and parse unquoted attribute values
- Loading branch information
Showing
10 changed files
with
1,082 additions
and
3 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
4 changes: 4 additions & 0 deletions
4
crates/biome_html_parser/tests/html_specs/error/attributes/invalid-unqouted-value1.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,4 @@ | ||
<div> | ||
<div class== >foo</div> | ||
<div class=? >foo</div> | ||
</div> |
251 changes: 251 additions & 0 deletions
251
crates/biome_html_parser/tests/html_specs/error/attributes/invalid-unqouted-value1.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,251 @@ | ||
--- | ||
source: crates/biome_html_parser/tests/spec_test.rs | ||
expression: snapshot | ||
--- | ||
## Input | ||
|
||
```html | ||
<div> | ||
<div class== >foo</div> | ||
<div class=? >foo</div> | ||
</div> | ||
``` | ||
|
||
|
||
## AST | ||
|
||
``` | ||
HtmlRoot { | ||
bom_token: missing (optional), | ||
directive: missing (optional), | ||
html: 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 [ | ||
HtmlBogusElement { | ||
items: [ | ||
HtmlBogus { | ||
items: [ | ||
L_ANGLE@5..8 "<" [Newline("\n"), Whitespace("\t")] [], | ||
HtmlName { | ||
value_token: HTML_LITERAL@8..12 "div" [] [Whitespace(" ")], | ||
}, | ||
HtmlBogus { | ||
items: [ | ||
HtmlAttribute { | ||
name: HtmlName { | ||
value_token: HTML_LITERAL@12..17 "class" [] [], | ||
}, | ||
initializer: HtmlAttributeInitializerClause { | ||
eq_token: EQ@17..18 "=" [] [], | ||
value: missing (required), | ||
}, | ||
}, | ||
HtmlBogusElement { | ||
items: [ | ||
ERROR_TOKEN@18..20 "=" [] [Whitespace(" ")], | ||
], | ||
}, | ||
], | ||
}, | ||
R_ANGLE@20..21 ">" [] [], | ||
], | ||
}, | ||
HtmlElementList [ | ||
HtmlContent { | ||
value_token: HTML_LITERAL@21..24 "foo" [] [], | ||
}, | ||
], | ||
HtmlClosingElement { | ||
l_angle_token: L_ANGLE@24..25 "<" [] [], | ||
slash_token: SLASH@25..26 "/" [] [], | ||
name: HtmlName { | ||
value_token: HTML_LITERAL@26..29 "div" [] [], | ||
}, | ||
r_angle_token: R_ANGLE@29..30 ">" [] [], | ||
}, | ||
], | ||
}, | ||
HtmlBogusElement { | ||
items: [ | ||
HtmlBogus { | ||
items: [ | ||
L_ANGLE@30..33 "<" [Newline("\n"), Whitespace("\t")] [], | ||
HtmlName { | ||
value_token: HTML_LITERAL@33..37 "div" [] [Whitespace(" ")], | ||
}, | ||
HtmlBogus { | ||
items: [ | ||
HtmlAttribute { | ||
name: HtmlName { | ||
value_token: HTML_LITERAL@37..42 "class" [] [], | ||
}, | ||
initializer: HtmlAttributeInitializerClause { | ||
eq_token: EQ@42..43 "=" [] [], | ||
value: missing (required), | ||
}, | ||
}, | ||
HtmlBogusElement { | ||
items: [ | ||
ERROR_TOKEN@43..45 "?" [] [Whitespace(" ")], | ||
], | ||
}, | ||
], | ||
}, | ||
R_ANGLE@45..46 ">" [] [], | ||
], | ||
}, | ||
HtmlElementList [ | ||
HtmlContent { | ||
value_token: HTML_LITERAL@46..49 "foo" [] [], | ||
}, | ||
], | ||
HtmlClosingElement { | ||
l_angle_token: L_ANGLE@49..50 "<" [] [], | ||
slash_token: SLASH@50..51 "/" [] [], | ||
name: HtmlName { | ||
value_token: HTML_LITERAL@51..54 "div" [] [], | ||
}, | ||
r_angle_token: R_ANGLE@54..55 ">" [] [], | ||
}, | ||
], | ||
}, | ||
], | ||
closing_element: HtmlClosingElement { | ||
l_angle_token: L_ANGLE@55..57 "<" [Newline("\n")] [], | ||
slash_token: SLASH@57..58 "/" [] [], | ||
name: HtmlName { | ||
value_token: HTML_LITERAL@58..61 "div" [] [], | ||
}, | ||
r_angle_token: R_ANGLE@61..62 ">" [] [], | ||
}, | ||
}, | ||
eof_token: EOF@62..63 "" [Newline("\n")] [], | ||
} | ||
``` | ||
|
||
## CST | ||
|
||
``` | ||
0: [email protected] | ||
0: (empty) | ||
1: (empty) | ||
2: [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] "<" [Newline("\n"), Whitespace("\t")] [] | ||
1: [email protected] | ||
0: [email protected] "div" [] [Whitespace(" ")] | ||
2: [email protected] | ||
0: [email protected] | ||
0: [email protected] | ||
0: [email protected] "class" [] [] | ||
1: [email protected] | ||
0: [email protected] "=" [] [] | ||
1: (empty) | ||
1: [email protected] | ||
0: [email protected] "=" [] [Whitespace(" ")] | ||
3: [email protected] ">" [] [] | ||
1: [email protected] | ||
0: [email protected] | ||
0: [email protected] "foo" [] [] | ||
2: [email protected] | ||
0: [email protected] "<" [] [] | ||
1: [email protected] "/" [] [] | ||
2: [email protected] | ||
0: [email protected] "div" [] [] | ||
3: [email protected] ">" [] [] | ||
1: [email protected] | ||
0: [email protected] | ||
0: [email protected] "<" [Newline("\n"), Whitespace("\t")] [] | ||
1: [email protected] | ||
0: [email protected] "div" [] [Whitespace(" ")] | ||
2: [email protected] | ||
0: [email protected] | ||
0: [email protected] | ||
0: [email protected] "class" [] [] | ||
1: [email protected] | ||
0: [email protected] "=" [] [] | ||
1: (empty) | ||
1: [email protected] | ||
0: [email protected] "?" [] [Whitespace(" ")] | ||
3: [email protected] ">" [] [] | ||
1: [email protected] | ||
0: [email protected] | ||
0: [email protected] "foo" [] [] | ||
2: [email protected] | ||
0: [email protected] "<" [] [] | ||
1: [email protected] "/" [] [] | ||
2: [email protected] | ||
0: [email protected] "div" [] [] | ||
3: [email protected] ">" [] [] | ||
2: [email protected] | ||
0: [email protected] "<" [Newline("\n")] [] | ||
1: [email protected] "/" [] [] | ||
2: [email protected] | ||
0: [email protected] "div" [] [] | ||
3: [email protected] ">" [] [] | ||
3: [email protected] "" [Newline("\n")] [] | ||
``` | ||
|
||
## Diagnostics | ||
|
||
``` | ||
invalid-unqouted-value1.html:2:13 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
× Unexpected character in unquoted attribute value | ||
1 │ <div> | ||
> 2 │ <div class== >foo</div> | ||
│ ^ | ||
3 │ <div class=? >foo</div> | ||
4 │ </div> | ||
invalid-unqouted-value1.html:2:13 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
× Unexpected character `=` | ||
1 │ <div> | ||
> 2 │ <div class== >foo</div> | ||
│ ^ | ||
3 │ <div class=? >foo</div> | ||
4 │ </div> | ||
invalid-unqouted-value1.html:3:13 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
× Unexpected character in unquoted attribute value | ||
1 │ <div> | ||
2 │ <div class== >foo</div> | ||
> 3 │ <div class=? >foo</div> | ||
│ ^ | ||
4 │ </div> | ||
5 │ | ||
invalid-unqouted-value1.html:3:13 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
× Unexpected character `?` | ||
1 │ <div> | ||
2 │ <div class== >foo</div> | ||
> 3 │ <div class=? >foo</div> | ||
│ ^ | ||
4 │ </div> | ||
5 │ | ||
``` |
4 changes: 4 additions & 0 deletions
4
crates/biome_html_parser/tests/html_specs/error/attributes/invalid-unquoted-value2.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,4 @@ | ||
<div> | ||
<div class=foo"bar >foo</div> | ||
<div class=foo'bar >foo</div> | ||
</div> |
Oops, something went wrong.