Repository navigation
Autoresearch r2 - #76
Conversation
📝 WalkthroughWalkthroughChangesThe DOM walker adds Pure-mode early returns for eligible spans and unregistered elements, with math-span detection and normalized child content. Preformatted subtree behavior is tested, while anchor escaping and list-item trimming reduce intermediate allocations. Pure-mode content handling
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant DOM
participant walk_node
participant walk_children
participant ContentBuffer
DOM->>walk_node: visit element
walk_node->>walk_children: traverse Pure-mode children
walk_children-->>walk_node: child content
walk_node->>ContentBuffer: append normalized content
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/dom_walker.rs (1)
148-156: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winMake math span detection more robust.
The current check strictly requires exactly one attribute (
class) and an exact string match. This is brittle and might skip valid math spans that happen to include additional attributes (such asidoraria-hidden) or reordered classes, causing them to be processed as normal spans.Consider relaxing the check to search for the required classes across all attributes.
♻️ Proposed refactor
fn is_math_span(attrs: &[html5ever::Attribute]) -> bool { - attrs.len() == 1 - && attrs[0].name.local.as_ref() == "class" - && matches!( - attrs[0].value.as_ref(), - "math math-inline" | "math math-display" - ) + attrs.iter().any(|attr| { + attr.name.local.as_ref() == "class" && { + let val = attr.value.as_ref(); + val.contains("math-inline") || val.contains("math-display") + } + }) }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/dom_walker.rs` around lines 148 - 156, Update is_math_span to inspect all attributes for a class attribute containing both “math” and either “math-inline” or “math-display”, regardless of attribute count or class ordering. Preserve false for elements without the required class tokens.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/dom_walker.rs`:
- Around line 148-156: Update is_math_span to inspect all attributes for a class
attribute containing both “math” and either “math-inline” or “math-display”,
regardless of attribute count or class ordering. Preserve false for elements
without the required class tokens.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: d54a9f38-36dd-4f0d-b1c6-4b4b45e25082
⛔ Files ignored due to path filters (1)
benches/results.tsvis excluded by!**/*.tsv
📒 Files selected for processing (5)
src/dom_walker.rssrc/element_handler/anchor.rssrc/element_handler/li.rssrc/element_handler/mod.rstests/basic_tests.rs
Summary by CodeRabbit