Conversation
|
Merging this PR will not alter performance
Comparing Footnotes
|
WalkthroughThis PR threads a new Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
crates/biome_markdown_formatter/src/markdown/auxiliary/inline_italic.rs (1)
39-47: Consider using||instead of|for boolean OR.Line 44 uses bitwise OR (
|) rather than logical OR (||). Both work for bools, but||is more idiomatic in Rust for boolean conditions. The difference is minor here sinceself.should_keep_fencesis a simple field access, but||makes the intent clearer.✨ Optional: use logical OR
if node .syntax() .ancestors() .skip(1) .any(|a| MdReferenceImage::can_cast(a.kind())) - | self.should_keep_fences + || self.should_keep_fences { return write!(f, [l_fence.format(), content.format(), r_fence.format()]); }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@crates/biome_markdown_formatter/src/markdown/auxiliary/inline_italic.rs` around lines 39 - 47, The conditional combines the ancestor check and the field self.should_keep_fences using a bitwise OR; replace the bitwise OR (`|`) with a logical OR (`||`) so the condition reads "...any(|a| MdReferenceImage::can_cast(a.kind())) || self.should_keep_fences" (the branch that returns write!(f, [l_fence.format(), content.format(), r_fence.format()]) inside the inline italic formatter). This uses the idiomatic boolean operator and preserves short-circuiting semantics when evaluating self.should_keep_fences.crates/biome_markdown_formatter/src/markdown/auxiliary/setext_header.rs (1)
18-25: Minor formatting inconsistency.There's a trailing comma after
token("#")on line 20 but not aftertoken("##")on line 24. Either style is fine, but consistency would be tidier.✨ Optional: consistent trailing comma
// h1 if underline_token.token_text_trimmed().starts_with("=") { - write!(f, [token("#"),])?; + write!(f, [token("#")])?; } // h2 else {🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@crates/biome_markdown_formatter/src/markdown/auxiliary/setext_header.rs` around lines 18 - 25, The two write! calls in setext_header handling h1/h2 are inconsistent: write!(f, [token("#"),]) has a trailing comma while write!(f, [token("##"),]) does not; make them consistent by adding or removing the trailing comma in the other call so both write!(f, [token("#"),]) and write!(f, [token("##"),]) use the same punctuation style (update the occurrences around underline_token.token_text_trimmed() in setext_header.rs).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@crates/biome_markdown_formatter/src/markdown/lists/inline_item_list.rs`:
- Around line 341-345: The doc comment on the struct
FormatMdFormatInlineItemListOptions has a typo: change "instructions the
formatter to keep the fences." to "instructs the formatter to keep the fences."
in the comment for the keep_fences_in_italics field so the grammar is correct
and consistent.
- Around line 12-13: Fix the typo in the doc comment for the struct field
keep_fences_in_italics: change "instrustructs" to "instructs" in the
triple-slash comment that documents keep_fences_in_italics so the comment reads
"When true, and there's a [MdInlineItalic], it instructs the formatter to keep
the fences".
---
Nitpick comments:
In `@crates/biome_markdown_formatter/src/markdown/auxiliary/inline_italic.rs`:
- Around line 39-47: The conditional combines the ancestor check and the field
self.should_keep_fences using a bitwise OR; replace the bitwise OR (`|`) with a
logical OR (`||`) so the condition reads "...any(|a|
MdReferenceImage::can_cast(a.kind())) || self.should_keep_fences" (the branch
that returns write!(f, [l_fence.format(), content.format(), r_fence.format()])
inside the inline italic formatter). This uses the idiomatic boolean operator
and preserves short-circuiting semantics when evaluating
self.should_keep_fences.
In `@crates/biome_markdown_formatter/src/markdown/auxiliary/setext_header.rs`:
- Around line 18-25: The two write! calls in setext_header handling h1/h2 are
inconsistent: write!(f, [token("#"),]) has a trailing comma while write!(f,
[token("##"),]) does not; make them consistent by adding or removing the
trailing comma in the other call so both write!(f, [token("#"),]) and write!(f,
[token("##"),]) use the same punctuation style (update the occurrences around
underline_token.token_text_trimmed() in setext_header.rs).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 392a0b69-3ad8-435f-9ebe-29043ee47ee3
⛔ Files ignored due to path filters (27)
Cargo.lockis excluded by!**/*.lockand included by**crates/biome_markdown_formatter/tests/specs/markdown/reference_link.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_formatter/tests/specs/markdown/setext_header.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_formatter/tests/specs/prettier/markdown/linkReference/case-and-space/case-and-space.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_formatter/tests/specs/prettier/markdown/list/checkbox.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_formatter/tests/specs/prettier/markdown/list/indent.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_formatter/tests/specs/prettier/markdown/markdown/test-case.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_formatter/tests/specs/prettier/markdown/spec/example-108.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_formatter/tests/specs/prettier/markdown/spec/example-259.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_formatter/tests/specs/prettier/markdown/spec/example-27.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_formatter/tests/specs/prettier/markdown/spec/example-49.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_formatter/tests/specs/prettier/markdown/spec/example-50.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_formatter/tests/specs/prettier/markdown/spec/example-51.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_formatter/tests/specs/prettier/markdown/spec/example-518.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_formatter/tests/specs/prettier/markdown/spec/example-52.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_formatter/tests/specs/prettier/markdown/spec/example-54.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_formatter/tests/specs/prettier/markdown/spec/example-57.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_formatter/tests/specs/prettier/markdown/spec/example-59.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_formatter/tests/specs/prettier/markdown/spec/example-63.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_formatter/tests/specs/prettier/markdown/spec/example-64.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_formatter/tests/specs/prettier/markdown/spec/example-70.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_formatter/tests/specs/prettier/markdown/spec/example-71.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_formatter/tests/specs/prettier/markdown/spec/example-79.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_formatter/tests/specs/prettier/markdown/spec/example-80.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_formatter/tests/specs/prettier/markdown/spec/example-83.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_formatter/tests/specs/prettier/markdown/yaml/simple-2.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_formatter/tests/specs/prettier/markdown/yaml/simple.md.snapis excluded by!**/*.snapand included by**
📒 Files selected for processing (21)
crates/biome_markdown_formatter/Cargo.tomlcrates/biome_markdown_formatter/src/markdown/auxiliary/autolink.rscrates/biome_markdown_formatter/src/markdown/auxiliary/continuation_indent.rscrates/biome_markdown_formatter/src/markdown/auxiliary/fenced_code_block.rscrates/biome_markdown_formatter/src/markdown/auxiliary/hard_line.rscrates/biome_markdown_formatter/src/markdown/auxiliary/indent_code_block.rscrates/biome_markdown_formatter/src/markdown/auxiliary/inline_code.rscrates/biome_markdown_formatter/src/markdown/auxiliary/inline_image.rscrates/biome_markdown_formatter/src/markdown/auxiliary/inline_italic.rscrates/biome_markdown_formatter/src/markdown/auxiliary/inline_link.rscrates/biome_markdown_formatter/src/markdown/auxiliary/link_destination.rscrates/biome_markdown_formatter/src/markdown/auxiliary/link_label.rscrates/biome_markdown_formatter/src/markdown/auxiliary/link_title.rscrates/biome_markdown_formatter/src/markdown/auxiliary/newline.rscrates/biome_markdown_formatter/src/markdown/auxiliary/paragraph.rscrates/biome_markdown_formatter/src/markdown/auxiliary/reference_link.rscrates/biome_markdown_formatter/src/markdown/auxiliary/setext_header.rscrates/biome_markdown_formatter/src/markdown/lists/inline_item_list.rscrates/biome_markdown_formatter/tests/quick_test.rscrates/biome_markdown_formatter/tests/specs/markdown/reference_link.mdcrates/biome_markdown_formatter/tests/specs/markdown/setext_header.md
7e3dbaa to
c06805e
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@crates/biome_markdown_formatter/src/markdown/auxiliary/inline_italic.rs`:
- Line 44: The conditional expression currently uses the bitwise OR operator
('|') with self.should_keep_fences, which prevents short-circuiting; update the
condition in the function/block that contains self.should_keep_fences (the same
expression that checks the ancestor condition) to use the logical OR operator
('||') instead so the ancestor check short-circuits and self.should_keep_fences
is only evaluated when needed.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: e84d2355-b806-4fc8-97d4-5030b0c80224
⛔ Files ignored due to path filters (27)
Cargo.lockis excluded by!**/*.lockand included by**crates/biome_markdown_formatter/tests/specs/markdown/reference_link.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_formatter/tests/specs/markdown/setext_header.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_formatter/tests/specs/prettier/markdown/linkReference/case-and-space/case-and-space.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_formatter/tests/specs/prettier/markdown/list/checkbox.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_formatter/tests/specs/prettier/markdown/list/indent.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_formatter/tests/specs/prettier/markdown/markdown/test-case.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_formatter/tests/specs/prettier/markdown/spec/example-108.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_formatter/tests/specs/prettier/markdown/spec/example-259.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_formatter/tests/specs/prettier/markdown/spec/example-27.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_formatter/tests/specs/prettier/markdown/spec/example-49.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_formatter/tests/specs/prettier/markdown/spec/example-50.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_formatter/tests/specs/prettier/markdown/spec/example-51.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_formatter/tests/specs/prettier/markdown/spec/example-518.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_formatter/tests/specs/prettier/markdown/spec/example-52.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_formatter/tests/specs/prettier/markdown/spec/example-54.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_formatter/tests/specs/prettier/markdown/spec/example-57.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_formatter/tests/specs/prettier/markdown/spec/example-59.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_formatter/tests/specs/prettier/markdown/spec/example-63.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_formatter/tests/specs/prettier/markdown/spec/example-64.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_formatter/tests/specs/prettier/markdown/spec/example-70.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_formatter/tests/specs/prettier/markdown/spec/example-71.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_formatter/tests/specs/prettier/markdown/spec/example-79.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_formatter/tests/specs/prettier/markdown/spec/example-80.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_formatter/tests/specs/prettier/markdown/spec/example-83.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_formatter/tests/specs/prettier/markdown/yaml/simple-2.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_formatter/tests/specs/prettier/markdown/yaml/simple.md.snapis excluded by!**/*.snapand included by**
📒 Files selected for processing (21)
crates/biome_markdown_formatter/Cargo.tomlcrates/biome_markdown_formatter/src/markdown/auxiliary/autolink.rscrates/biome_markdown_formatter/src/markdown/auxiliary/continuation_indent.rscrates/biome_markdown_formatter/src/markdown/auxiliary/fenced_code_block.rscrates/biome_markdown_formatter/src/markdown/auxiliary/hard_line.rscrates/biome_markdown_formatter/src/markdown/auxiliary/indent_code_block.rscrates/biome_markdown_formatter/src/markdown/auxiliary/inline_code.rscrates/biome_markdown_formatter/src/markdown/auxiliary/inline_image.rscrates/biome_markdown_formatter/src/markdown/auxiliary/inline_italic.rscrates/biome_markdown_formatter/src/markdown/auxiliary/inline_link.rscrates/biome_markdown_formatter/src/markdown/auxiliary/link_destination.rscrates/biome_markdown_formatter/src/markdown/auxiliary/link_label.rscrates/biome_markdown_formatter/src/markdown/auxiliary/link_title.rscrates/biome_markdown_formatter/src/markdown/auxiliary/newline.rscrates/biome_markdown_formatter/src/markdown/auxiliary/paragraph.rscrates/biome_markdown_formatter/src/markdown/auxiliary/reference_link.rscrates/biome_markdown_formatter/src/markdown/auxiliary/setext_header.rscrates/biome_markdown_formatter/src/markdown/lists/inline_item_list.rscrates/biome_markdown_formatter/tests/quick_test.rscrates/biome_markdown_formatter/tests/specs/markdown/reference_link.mdcrates/biome_markdown_formatter/tests/specs/markdown/setext_header.md
✅ Files skipped from review due to trivial changes (11)
- crates/biome_markdown_formatter/src/markdown/auxiliary/fenced_code_block.rs
- crates/biome_markdown_formatter/src/markdown/auxiliary/hard_line.rs
- crates/biome_markdown_formatter/src/markdown/auxiliary/inline_code.rs
- crates/biome_markdown_formatter/src/markdown/auxiliary/link_label.rs
- crates/biome_markdown_formatter/Cargo.toml
- crates/biome_markdown_formatter/src/markdown/auxiliary/inline_link.rs
- crates/biome_markdown_formatter/src/markdown/auxiliary/newline.rs
- crates/biome_markdown_formatter/src/markdown/auxiliary/link_destination.rs
- crates/biome_markdown_formatter/src/markdown/auxiliary/inline_image.rs
- crates/biome_markdown_formatter/tests/specs/markdown/reference_link.md
- crates/biome_markdown_formatter/tests/quick_test.rs
🚧 Files skipped from review as they are similar to previous changes (8)
- crates/biome_markdown_formatter/src/markdown/auxiliary/autolink.rs
- crates/biome_markdown_formatter/src/markdown/auxiliary/paragraph.rs
- crates/biome_markdown_formatter/src/markdown/auxiliary/link_title.rs
- crates/biome_markdown_formatter/src/markdown/auxiliary/continuation_indent.rs
- crates/biome_markdown_formatter/src/markdown/auxiliary/indent_code_block.rs
- crates/biome_markdown_formatter/src/markdown/auxiliary/setext_header.rs
- crates/biome_markdown_formatter/src/markdown/auxiliary/reference_link.rs
- crates/biome_markdown_formatter/src/markdown/lists/inline_item_list.rs
| .ancestors() | ||
| .skip(1) | ||
| .any(|a| MdReferenceImage::can_cast(a.kind())) | ||
| | self.should_keep_fences |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Verify the boolean operator usage at the relevant site.
rg -nP --type=rust '\.any\(\|a\|\s*MdReferenceImage::can_cast\(a\.kind\(\)\)\)\s*\|\s*self\.should_keep_fences' crates/biome_markdown_formatter/src/markdown/auxiliary/inline_italic.rsRepository: biomejs/biome
Length of output: 39
🏁 Script executed:
cat -n crates/biome_markdown_formatter/src/markdown/auxiliary/inline_italic.rs | sed -n '35,55p'Repository: biomejs/biome
Length of output: 1029
Use || instead of | on line 44.
The condition currently uses bitwise OR, which doesn't short-circuit. Swapping to logical OR is idiomatic and avoids evaluating self.should_keep_fences if the ancestor check is already true.
Suggested fix
if node
.syntax()
.ancestors()
.skip(1)
.any(|a| MdReferenceImage::can_cast(a.kind()))
- | self.should_keep_fences
+ || self.should_keep_fences
{📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| | self.should_keep_fences | |
| if node | |
| .syntax() | |
| .ancestors() | |
| .skip(1) | |
| .any(|a| MdReferenceImage::can_cast(a.kind())) | |
| || self.should_keep_fences | |
| { |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@crates/biome_markdown_formatter/src/markdown/auxiliary/inline_italic.rs` at
line 44, The conditional expression currently uses the bitwise OR operator ('|')
with self.should_keep_fences, which prevents short-circuiting; update the
condition in the function/block that contains self.should_keep_fences (the same
expression that checks the ancestor condition) to use the logical OR operator
('||') instead so the ancestor check short-circuits and self.should_keep_fences
is only evaluated when needed.
Summary
More formatter markdown advancements:
Prettier transforms STX headers into ATX headers.
Also added logic to keep the fences of italics in some cases.
Test Plan
Added new test
Docs