Skip to content

Cleanup - #67

Merged
letmutex merged 5 commits into
letmutex:mainfrom
bjones1:cleanup
Dec 16, 2025
Merged

letmutex merged 5 commits into
letmutex:mainfrom
bjones1:cleanup

Conversation

@bjones1

@bjones1 bjones1 commented Dec 9, 2025 •

Copy link
Copy Markdown
Contributor

This builds on top of #66. Please merge it first.

This PR updates dependencies and applies fixes from cargo fmt and cargo clippy.

Summary by CodeRabbit

  • New Features

    • Added support for rendering inline and display mathematical expressions in HTML→Markdown conversion.
  • Chores

    • Updated several project dependencies to newer stable versions for improved compatibility.
  • Tests

    • Added tests verifying math rendering and proper escaping of characters inside math content.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Dec 9, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

Adds 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

Cohort / File(s) Summary
Dependency updates
Cargo.toml
Bumped html5ever and markup5ever_rcdom to 0.36; bumped dev-deps scraper to 0.25 and criterion to 0.8 (with html_reports).
Span / math handling
src/element_handler/span.rs, src/element_handler/mod.rs
Added new span module and span_handler; registered handler for span; detects class="math math-inline" and class="math math-display" and emits $...$ or $$...$$; non-math spans serialized in faithful mode or traverse children for inner text.
Type-cast fix
src/element_handler/element_util.rs
Cast attribute count to i64 in serialize_if_faithful comparison so sentinel -1 and comparison types align.
Formatting-only change
src/element_handler/table.rs
Minor brace/formatting adjustment in an if block; no logic change.
Tests
tests/basic_tests.rs
Switched attribute check from find(...).is_some() to any(...); added math() test verifying inline and display math rendering and escaping.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • Review span handler class-matching and wrapping logic for inline vs display math.
  • Verify i64 cast preserves sentinel behavior in serialize_if_faithful.
  • Confirm new test expectations and that dependency bumps compile.

Poem

🐰 I found a span that loved to count and play,
It wrapped its math in dollars, bright as day,
A cast was fixed, dependencies aligned,
Tests hop, pass, and leave no bug behind,
Hooray for spans — now math leaps out to say! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Cleanup' is vague and generic, using a non-descriptive term that does not convey meaningful information about the specific changes made in the changeset. Consider a more descriptive title that highlights the main change, such as 'Update dependencies and apply clippy fixes' or 'Bump html5ever, scraper, and criterion versions'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8217d85 and f7c4399.

📒 Files selected for processing (2)
  • Cargo.toml (1 hunks)
  • src/element_handler/mod.rs (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/element_handler/mod.rs
  • Cargo.toml

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 and usage tips.

@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: 0

🧹 Nitpick comments (1)
src/element_handler/mod.rs (1)

26-26: Consider moving span_handler to local imports for consistency.

The span_handler import follows the pattern of serialize_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

📥 Commits

Reviewing files that changed from the base of the PR and between 3d71970 and 8217d85.

📒 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 scraper and criterion updates to 0.25 and 0.8 respectively are appropriate version bumps.


15-16: The specified dependency versions do not exist on crates.io.

html5ever version 0.36.0 is not published—the latest stable release is 0.35.0, with newer versions starting at 0.36.1. Similarly, markup5ever_rcdom 0.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 fmt with no behavioral impact.

tests/basic_tests.rs (2)

552-552: LGTM!

Using any() instead of find(...).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 i64 is necessary to support -1 as a sentinel value for unconditional faithful-mode serialization, since len() returns usize which 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 -1 to serialize_if_faithful! means non-math spans will always be serialized as HTML in faithful mode, which aligns with the test expectation in paragraphs() (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 span module 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 was referenced Dec 10, 2025
@letmutex
letmutex merged commit f7c4399 into letmutex:main Dec 16, 2025
@bjones1
bjones1 deleted the cleanup branch December 16, 2025 14:02
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.

2 participants