Skip to content

Don't let unbalanced brackets in Pug text leak into the next line - #20547

Open
cestercian wants to merge 5 commits into
tailwindlabs:mainfrom
cestercian:fix/pug-unbalanced-text-brackets
Open

cestercian wants to merge 5 commits into
tailwindlabs:mainfrom
cestercian:fix/pug-unbalanced-text-brackets

Conversation

@cestercian

Copy link
Copy Markdown

Summary

Fixes #20545

The Pug pre-processor keeps one bracket stack for the whole file. A text or comment line with an unbalanced bracket, like | (, pushes a ( that is never popped, and from then on dots are no longer turned into spaces. So span.underline.font-bold on the next line stays one invalid candidate and those classes never get CSS.

This resets the bracket stack at the end of a line, unless we're inside a Pug attribute list (a ( directly after a tag, class, id or mixin name), since those can span multiple lines. Inside an attribute list the behavior is the same as before.

Test plan

Added unit tests in pug.rs for the cases from the issue (piped text, a //- comment, inline text after a tag) plus a multi-line attribute list to make sure that still works. The new test fails without the change.

cargo test -p tailwindcss-oxide

All 122 unit tests and 71 scanner tests pass.

@cestercian
cestercian requested a review from a team as a code owner October 6, 2026 11:07
@coderabbitai

coderabbitai Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 065c9907-f6bf-4887-8683-e0813b40820f
📥 Commits

Reviewing files that changed from the base of the PR and between d1dcaa7 and 24fb75a.

📒 Files selected for processing (1)
  • crates/oxide/src/extractor/pre_processors/pug.rs

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.


Walkthrough

Pug preprocessing now resets unmatched bracket state at newlines outside attribute lists. It tracks attribute lists that span multiple lines and clears that state when the outer bracket closes. Tests cover class extraction after unbalanced brackets in text and comments, and class extraction within and after multiline attribute lists. The Unreleased changelog records the fix.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 24fb7

The change is mergeable after normal checks. A narrow Pug attribute-value edge case remains but does not block the fix.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: preventing unbalanced brackets in Pug text from affecting class extraction on later lines.
Description check ✅ Passed The description explains the bracket-stack issue, the line-boundary behavior, and the tests added for text, comments, and multiline attribute lists.
Linked Issues check ✅ Passed Issue #20545 requires unmatched brackets in Pug text or comments not to affect class extraction on later lines, while preserving multiline attribute lists. Pug::process resets the bracket stack at l…
Out of Scope Changes check ✅ Passed The pug.rs changes and tests address issue #20545. The block-expansion whitespace tracking preserves recognition of multiline attribute lists after repeated spaces or tabs. The changelog entry docum…
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium risk] Fixes bracket tracking in Pug template text extraction.

The PR appears safe to merge; no new actionable issue or outstanding previous finding remains.

Reviews (4) · Last reviewed commit: "Track block-expansion whitespace without..." · Reviewed by Greptile

Comment thread crates/oxide/src/extractor/pre_processors/pug.rs Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: bd50a8b8-14e5-400b-8b7d-fac552fb128e
📥 Commits

Reviewing files that changed from the base of the PR and between fa81d69 and c577244.

📒 Files selected for processing (2)
  • CHANGELOG.md
  • crates/oxide/src/extractor/pre_processors/pug.rs

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Comment thread crates/oxide/src/extractor/pre_processors/pug.rs Outdated
Comment thread crates/oxide/src/extractor/pre_processors/pug.rs Outdated
Repeated spaces or tabs after `:` (e.g. `li:  a(`) no longer clear
in_tag, so the `(` is still treated as a multiline attribute list.
Comment thread crates/oxide/src/extractor/pre_processors/pug.rs Outdated
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.

Pug: classes not extracted after a text line with an unbalanced (

1 participant