Skip to content

🐛 HTML parser: false "Unexpected value or character" on text starting with "of" since 2.4.14 #10271

@andrew-hesse

Description

@andrew-hesse

Environment information

Details
CLI:
  Version:                      2.4.14
  Color support:                true

Platform:
  CPU Architecture:             aarch64
  OS:                           macos

Environment:
  JS_RUNTIME_VERSION:           v25.9.0
  JS_RUNTIME_NAME:              node

What happened?

Since 2.4.14, the HTML parser rejects any text node that starts with the word of. The same input parses cleanly on 2.4.13.

Minimal repro (.html or .astro):

<p>of</p>

Output:

test.html:1:4 parse
  × Unexpected value or character.
  > 1 │ <p>of</p>
      │    ^^
  i Expected one of:
  - element
  - text

A few notes from poking at it:

  • Only the literal word of triggers it. for, in, from, as, typeof, etc. are all fine.
  • Only matters when of is the first token of a text node. <p>The of</p> parses fine; <p>of Y</p> does not.
  • Common case in real content is after a closing inline tag: <p>The <strong>X</strong> of Y.</p> fails because the space after </strong> starts a new text node beginning with of.
  • Affects both the HTML and Astro parsers (shared lexer).

Bisected to 2.4.14:

Version <p>of</p>
2.4.10 OK
2.4.11 OK
2.4.12 OK
2.4.13 OK
2.4.14 parse error

The only HTML-parser change in 2.4.14 is #10178 (fix(parse/html): relex keywords as text in text contexts), which looks like the likely source. That change taught the parser to relex html/doctype as text after void elements, and seems to have left of mis-classified as a non-text keyword in this position.

Steps to reproduce:

  1. mkdir biome-of-bug && cd biome-of-bug
  2. npm init -y && npm i -D @biomejs/biome@2.4.14
  3. printf '<p>of</p>\n' > test.html
  4. npx biome check test.html --files-ignore-unknown=false

Expected result

The parser should accept <p>of</p> as plain text content, identical to 2.4.13 behaviour.

Code of Conduct

  • I agree to follow Biome's Code of Conduct

Metadata

Metadata

Assignees

Labels

A-ParserArea: parserL-HTMLLanguage: HTML and super languagesS-Bug-confirmedStatus: report has been confirmed as a valid bug

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions