Repository navigation
Cleanup - #67
Cleanup#67
Conversation
WalkthroughAdds a span element handler that detects math spans and converts them to Markdown math notation; updates several dependencies and a type cast in attribute-count comparison; adds tests for math rendering and a small formatting change in table handling. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/element_handler/mod.rs (1)
26-26: Consider moving span_handler to local imports for consistency.The
span_handlerimport follows the pattern ofserialize_element(crate-level use), but other handler functions are imported locally (lines 32-54) since they're only used in the registration section. For consistency, consider moving this import to the local imports section.Apply this diff to align with the existing import pattern:
use crate::{ dom_walker::walk_node, - element_handler::{element_util::serialize_element, span::span_handler}, + element_handler::element_util::serialize_element, options::{Options, TranslationMode}, text_util::concat_strings, };Then add the local import after line 47:
use pre::pre_handler; +use span::span_handler; use std::{collections::HashMap, rc::Rc};
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
Cargo.toml(1 hunks)src/element_handler/element_util.rs(1 hunks)src/element_handler/mod.rs(3 hunks)src/element_handler/span.rs(1 hunks)src/element_handler/table.rs(1 hunks)tests/basic_tests.rs(2 hunks)
🧰 Additional context used
🧬 Code graph analysis (4)
tests/basic_tests.rs (2)
src/lib.rs (2)
convert(30-32)convert(106-144)tests/common/mod.rs (1)
convert(8-16)
src/element_handler/element_util.rs (2)
src/element_handler/mod.rs (2)
options(316-316)options(353-355)src/lib.rs (1)
options(171-174)
src/element_handler/mod.rs (2)
src/element_handler/element_util.rs (1)
serialize_element(46-177)src/element_handler/span.rs (1)
span_handler(10-36)
src/element_handler/span.rs (2)
src/element_handler/list.rs (1)
attr(88-88)src/element_handler/code.rs (1)
content(121-121)
🔇 Additional comments (10)
Cargo.toml (2)
20-21: Dev-dependency updates look good.The
scraperandcriterionupdates to 0.25 and 0.8 respectively are appropriate version bumps.
15-16: The specified dependency versions do not exist on crates.io.
html5everversion 0.36.0 is not published—the latest stable release is 0.35.0, with newer versions starting at 0.36.1. Similarly,markup5ever_rcdom0.36.0 is not available on crates.io. Update to valid versions (either keep 0.35.0 or upgrade to 0.36.1 or later if compatible with your code).Likely an incorrect or invalid review comment.
src/element_handler/table.rs (1)
126-127: LGTM!Formatting change applied by
cargo fmtwith no behavioral impact.tests/basic_tests.rs (2)
552-552: LGTM!Using
any()instead offind(...).is_some()is more idiomatic Rust. Good clippy fix.
656-673: Good test coverage for the new math span handling.Tests cover inline math, display math, and correctly verifies that special characters inside math spans are not escaped. The test at line 669-672 ensures characters like
{,_,*,[,],<,>, and\pass through unmodified within math content.src/element_handler/element_util.rs (1)
188-193: LGTM!The cast to
i64is necessary to support -1 as a sentinel value for unconditional faithful-mode serialization, sincelen()returnsusizewhich cannot represent negative values. The comment update clearly documents this behavior.src/element_handler/span.rs (2)
10-26: Math span detection logic looks correct.The handler correctly identifies math spans and wraps them with appropriate Markdown math delimiters. The restrictive matching (exactly 1 class attribute, exactly 1 text child) is appropriate for the common math span format from tools like KaTeX/MathJax.
28-35: Consider documenting the faithful-mode behavior for spans.Passing
-1toserialize_if_faithful!means non-math spans will always be serialized as HTML in faithful mode, which aligns with the test expectation inparagraphs()(line 150:"The <span>second.</span>"). The fallback for non-faithful mode correctly returns the inner content.src/element_handler/mod.rs (2)
17-17: LGTM: Module declaration is correct.The
spanmodule declaration is properly placed in alphabetical order and follows the established pattern.
180-181: LGTM: Handler registration is correctly placed.The span handler is properly registered and positioned before the generic block handlers, which is appropriate since span is an inline element requiring specific handling. The registration follows the established pattern and the handler's logic (from
span.rs) appropriately handles math spans while respecting translation modes for other spans.
This builds on top of #66. Please merge it first.
This PR updates dependencies and applies fixes from
cargo fmtandcargo clippy.Summary by CodeRabbit
New Features
Chores
Tests
✏️ Tip: You can customize this high-level summary in your review settings.