Skip to content

fix: remove stray f-string sub-rule that mis-highlights PRQL f-strings - #6095

Merged
max-sixty merged 1 commit into
mainfrom
fix/prql-highlight-fstring
Jul 22, 2026
Merged

fix: remove stray f-string sub-rule that mis-highlights PRQL f-strings#6095
max-sixty merged 1 commit into
mainfrom
fix/prql-highlight-fstring

Conversation

@prql-bot

Copy link
Copy Markdown
Collaborator

Nightly survey finding in the PRQL syntax-highlighting definition.

Stray f-string sub-rule (the fix). The f-string mode's contains held a sub-rule { scope: "variable", begin: "f", end: '"' }. The parent mode's begin is f", so the opening f prefix is already consumed before any child rule runs — this sub-rule could therefore only match a stray f inside the string body, starting a variable span that runs to the closing quote and mis-coloring the surrounding text. The parallel s-string block has no such rule. It was a leftover experiment (note the commented-out excludesEnd).

Verified empirically with highlight.js 11.11.1 on f"info {x}":

with the rule:    f"in<variable>fo {x}"</variable>     ← the `f` in "info" mis-highlights the rest
without the rule: f"info <variable>{x}</variable>"     ← only the interpolation is highlighted

Applied to both the book copy (web/book/highlight-prql.js) and the website copy (web/website/themes/prql-theme/static/plugins/highlight/prql.js), which the header comments ask to be kept consistent.

Stale comment (book copy only). Also removed a comment claiming mdBook exposes a minified highlight.js requiring abbreviated property names (b => begin, e => end, …). The definition objects below it use the full names (begin, end, contains, scope, match, keywords), so the comment is stale and would mislead an editor.

No repo test harness exists for the highlight definition, so there's no unit test to add; the behavior change is verified via the highlight.js run above.

@max-sixty
max-sixty merged commit 686bdcf into main Jul 22, 2026
37 checks passed
@max-sixty
max-sixty deleted the fix/prql-highlight-fstring branch July 22, 2026 02:12
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.

2 participants