Skip to content

fix: keep hexadecimal escape terminators inside words - #103

Open
feritcemkahraman wants to merge 1 commit into
postcss:mainfrom
feritcemkahraman:fix/hex-escape-whitespace
Open

feritcemkahraman wants to merge 1 commit into
postcss:mainfrom
feritcemkahraman:fix/hex-escape-whitespace

Conversation

@feritcemkahraman

Copy link
Copy Markdown

CSS hexadecimal escapes may consume up to six hexadecimal digits followed by one optional whitespace terminator. Currently fo\a o becomes three nodes, so consumers can treat a single CSS identifier as multiple values.

Consume the optional terminator while scanning words, preserving the original spelling and source offsets. Handle CRLF as one newline, leave subsequent whitespace as a separator, and keep punctuation after an escape available to the parser. This also corrects the existing Hawaii \35 -0 fixture: \35 -0 is one identifier.

Addresses the word-tokenization case in #64. Escape decoding in string values is outside this change.

Validation:

  • Before the fix, 8 of the 9 new regression cases fail.
  • pnpm test: all 175 tests pass.
  • pnpm lint: passes.
  • pnpm exec oxfmt lib/parse.js test/parse.js test/hex-escapes.js: applied.
  • git diff --check: passes.

Specification: https://www.w3.org/TR/css-syntax-3/#consume-escaped-code-point

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant