-
-
Notifications
You must be signed in to change notification settings - Fork 760
fix(html): parse frontmatter inside quotes #7907
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest commit: 344fec8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
WalkthroughAdds a quote-tracking mechanism (private Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
crates/biome_html_parser/src/lexer/mod.rs (1)
903-955: Consider clarifying the tracking logic comments.The tracking logic is sound for the use case, but the comments on lines 920–921, 930–931, and 941–942 could be more explicit about the state machine behaviour (i.e., increment when counter is zero and opening a quote; decrement when closing).
Example for line 920–921:
- /// It adds a single quote if single quotes are zero and the others are greater than zero. It removes it otherwise + /// Tracks a single quote: increments if opening (counter is zero), decrements if closing fn track_single(&mut self) {This improves readability without changing behaviour.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (10)
crates/biome_html_parser/tests/html_specs/error/astro/missing_fence.astro.snapis excluded by!**/*.snapand included by**crates/biome_html_parser/tests/html_specs/error/vue/vue_unclosed_expression.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_parser/tests/html_specs/ok/astro/frontmatter_in_quotes.astro.snapis excluded by!**/*.snapand included by**crates/biome_html_parser/tests/html_specs/ok/astro/no_fence.astro.snapis excluded by!**/*.snapand included by**crates/biome_html_parser/tests/html_specs/ok/astro/with_fence.astro.snapis excluded by!**/*.snapand included by**crates/biome_html_parser/tests/html_specs/ok/svelte/svelte_expressions.svelte.snapis excluded by!**/*.snapand included by**crates/biome_html_parser/tests/html_specs/ok/vue/interpolation.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_parser/tests/html_specs/ok/vue/multiple_expressions.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_parser/tests/html_specs/ok/vue/vue_expressions.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_parser/tests/html_specs/ok/vue/vue_expressions_escaped.vue.snapis excluded by!**/*.snapand included by**
📒 Files selected for processing (3)
.changeset/clean-streets-feel.md(1 hunks)crates/biome_html_parser/src/lexer/mod.rs(5 hunks)crates/biome_html_parser/tests/html_specs/ok/astro/frontmatter_in_quotes.astro(1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
.changeset/*.md
📄 CodeRabbit inference engine (CONTRIBUTING.md)
.changeset/*.md: In changeset files, only use #### or ##### headers
Changesets should describe user-facing changes; internal-only changes do not need changesets
Use past tense for what you did in the changeset description and present tense for current behavior
For bug fixes, start the changeset description with a link to the issue (e.g., Fixed #1234: ...)
When referencing a rule or assist in a changeset, include a link to the rule/assist page on the website
Include a code block in the changeset when applicable to illustrate the change
End every sentence in a changeset with a full stop (.)
Files:
.changeset/clean-streets-feel.md
**/*.{rs,toml}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Format Rust and TOML files before committing (e.g., via
just f)
Files:
crates/biome_html_parser/src/lexer/mod.rs
**/*.rs
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Document rules, assists, and their options with inline rustdoc in the Rust source
Files:
crates/biome_html_parser/src/lexer/mod.rs
🧠 Learnings (1)
📚 Learning: 2025-10-15T09:24:31.042Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_parser/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:24:31.042Z
Learning: Lexer must implement the biome_parser::Lexer trait
Applied to files:
crates/biome_html_parser/src/lexer/mod.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Test Node.js API
- GitHub Check: autofix
🔇 Additional comments (4)
crates/biome_html_parser/tests/html_specs/ok/astro/frontmatter_in_quotes.astro (1)
1-9: LGTM!This test case clearly validates the fix for parsing frontmatter when triple fences appear inside quoted strings.
Consider adding test coverage for edge cases such as escaped quotes (e.g.,
`\`---\``) or nested quote combinations to ensure robustness. However, this is optional and can be addressed in a follow-up if needed.crates/biome_html_parser/src/lexer/mod.rs (3)
14-14: LGTM!The
AddAssignimport is correctly added to support the in-place increment operations inQuotesSeen.
169-213: Quote tracking correctly prevents false frontmatter boundaries.The implementation properly tracks quote state whilst consuming embedded language content, allowing the lexer to distinguish between
---inside quotes and actual frontmatter boundaries.Note: The current implementation doesn't handle escaped quotes (e.g.,
`\`---`). Whilst this may be out of scope for the current issue, consider whether escaped quote handling is needed for production robustness. If desired, this could be addressed in a follow-up.
957-986: LGTM!The unit tests appropriately validate the core quote-tracking behaviour for balanced and unbalanced quote scenarios.
Summary
Closes #7839
I added a small utility that tracks the quotes while consuming characters inside a script, and if we're inside an Astro fence block. we check if there aren't any more quotes before emitting the correct token.
Test Plan
Added new tests
I also moved the testing files inside the relative folders (
vue/,svelte/andastro/)Docs