diff --git a/crates/biome_html_parser/src/lexer/mod.rs b/crates/biome_html_parser/src/lexer/mod.rs index 6c34edccd508..70cb844e9fc1 100644 --- a/crates/biome_html_parser/src/lexer/mod.rs +++ b/crates/biome_html_parser/src/lexer/mod.rs @@ -2,8 +2,8 @@ mod tests; use crate::token_source::HtmlLexContext; use biome_html_syntax::HtmlSyntaxKind::{ - COMMENT, DOCTYPE_KW, EOF, ERROR_TOKEN, HTML_LITERAL, HTML_STRING_LITERAL, NEWLINE, TOMBSTONE, - UNICODE_BOM, WHITESPACE, + COMMENT, DOCTYPE_KW, EOF, ERROR_TOKEN, HTML_KW, HTML_LITERAL, HTML_STRING_LITERAL, NEWLINE, + TOMBSTONE, UNICODE_BOM, WHITESPACE, }; use biome_html_syntax::{HtmlSyntaxKind, TextLen, TextSize, T}; use biome_parser::diagnostic::ParseDiagnostic; @@ -149,6 +149,7 @@ impl<'src> HtmlLexer<'src> { match &buffer[..len] { b"doctype" | b"DOCTYPE" => DOCTYPE_KW, + b"html" | b"HTML" => HTML_KW, _ => HTML_LITERAL, } } diff --git a/crates/biome_html_parser/src/lexer/tests.rs b/crates/biome_html_parser/src/lexer/tests.rs index f70fa882ffcb..8774b2378d1b 100644 --- a/crates/biome_html_parser/src/lexer/tests.rs +++ b/crates/biome_html_parser/src/lexer/tests.rs @@ -157,7 +157,7 @@ fn doctype_with_quirk() { BANG: 1, DOCTYPE_KW: 7, WHITESPACE: 1, - HTML_LITERAL: 4, + HTML_KW: 4, R_ANGLE: 1, } } @@ -170,7 +170,7 @@ fn doctype_with_quirk_and_system() { BANG: 1, DOCTYPE_KW: 7, WHITESPACE: 1, - HTML_LITERAL: 4, + HTML_KW: 4, WHITESPACE: 1, HTML_STRING_LITERAL: 44, R_ANGLE: 1, diff --git a/crates/biome_html_parser/src/syntax/mod.rs b/crates/biome_html_parser/src/syntax/mod.rs index 79a147948678..b46693d60d36 100644 --- a/crates/biome_html_parser/src/syntax/mod.rs +++ b/crates/biome_html_parser/src/syntax/mod.rs @@ -43,6 +43,10 @@ fn parse_doc_type(p: &mut HtmlParser) -> ParsedSyntax { p.eat(T![doctype]); } + if p.at(T![html]) { + p.eat(T![html]); + } + p.eat(T![>]); Present(m.complete(p, HTML_DIRECTIVE)) diff --git a/crates/biome_html_parser/tests/html_specs/ok/ok2.html b/crates/biome_html_parser/tests/html_specs/ok/ok2.html new file mode 100644 index 000000000000..c50eddd41fab --- /dev/null +++ b/crates/biome_html_parser/tests/html_specs/ok/ok2.html @@ -0,0 +1 @@ + diff --git a/crates/biome_html_parser/tests/html_specs/ok/ok2.html.snap b/crates/biome_html_parser/tests/html_specs/ok/ok2.html.snap new file mode 100644 index 000000000000..12fd5d64f1ae --- /dev/null +++ b/crates/biome_html_parser/tests/html_specs/ok/ok2.html.snap @@ -0,0 +1,50 @@ +--- +source: crates/biome_html_parser/tests/spec_test.rs +expression: snapshot +--- +## Input + +```css + + +``` + + +## AST + +``` +HtmlRoot { + bom_token: missing (optional), + directive: HtmlDirective { + l_angle_token: L_ANGLE@0..1 "<" [] [], + excl_token: BANG@1..2 "!" [] [], + doctype_token: DOCTYPE_KW@2..10 "doctype" [] [Whitespace(" ")], + html_token: HTML_KW@10..14 "html" [] [], + quirk_token: missing (optional), + public_id_token: missing (optional), + system_id_token: missing (optional), + r_angle_token: R_ANGLE@14..15 ">" [] [], + }, + html: missing (optional), + eof_token: EOF@15..16 "" [Newline("\n")] [], +} +``` + +## CST + +``` +0: HTML_ROOT@0..16 + 0: (empty) + 1: HTML_DIRECTIVE@0..15 + 0: L_ANGLE@0..1 "<" [] [] + 1: BANG@1..2 "!" [] [] + 2: DOCTYPE_KW@2..10 "doctype" [] [Whitespace(" ")] + 3: HTML_KW@10..14 "html" [] [] + 4: (empty) + 5: (empty) + 6: (empty) + 7: R_ANGLE@14..15 ">" [] [] + 2: (empty) + 3: EOF@15..16 "" [Newline("\n")] [] + +``` diff --git a/xtask/codegen/html.ungram b/xtask/codegen/html.ungram index 19ccd96f9e89..e7ee636c894c 100644 --- a/xtask/codegen/html.ungram +++ b/xtask/codegen/html.ungram @@ -116,7 +116,7 @@ HtmlAttribute = // -// ^^^^ +// ^^^ HtmlAttributeInitializerClause = '=' value: HtmlString