Skip to content

Fix Markdown parsing edge cases - #77

Merged
letmutex merged 3 commits into
mainfrom
fix/parsing-correctness
Jul 27, 2026
Merged

letmutex merged 3 commits into
mainfrom
fix/parsing-correctness

Conversation

@letmutex

@letmutex letmutex commented Jul 27, 2026 •

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • Bug Fixes

    • Improved fenced code block rendering by selecting fence lengths based on the longest run inside the content.
    • Enhanced inline code formatting to better avoid delimiter collisions and preserve boundary spacing for preformatted inline code.
    • Corrected image destination formatting when the URL contains spaces, ensuring the title appears after the closing delimiter.
    • Preserved additional table cells when body rows exceed header width and improved output for malformed table markup.
    • Ensured misnested inline emphasis/text isn’t duplicated or lost.
  • Tests

    • Added regression coverage for code rendering, image titles with spaced URLs, inline formatting edge cases, and table conversions.

@coderabbitai

coderabbitai Bot commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 916609a9-1dbe-4f20-a315-fa895f737d20

📥 Commits

Reviewing files that changed from the base of the PR and between 7bbc1d7 and 5bcabf9.

📒 Files selected for processing (3)
  • src/element_handler/code.rs
  • tests/basic_tests.rs
  • tests/code_tests.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/element_handler/code.rs

📝 Walkthrough

Walkthrough

Markdown rendering now selects collision-free code delimiters and fence lengths, formats image titles outside space-containing destinations, and preserves table cells beyond header width. Regression tests cover these behaviors plus malformed and misnested HTML cases.

Changes

Markdown rendering correctness

Layer / File(s) Summary
Code delimiter and fence selection
src/element_handler/code.rs, tests/code_tests.rs, tests/basic_tests.rs
Code rendering derives inline delimiters and fenced-code markers from conflicting backtick or tilde runs, preserves relevant preformatted spacing, and expands regression coverage.
Image links and inline formatting
src/element_handler/img.rs, tests/basic_tests.rs
Image links place titles after angle-bracketed destinations, and regression tests cover image titles and misnested inline formatting.
Table width and malformed markup preservation
src/element_handler/table.rs, tests/table_tests.rs
Table width includes the widest row, with tests confirming extra cells and visible text are retained.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

  • letmutex/htmd#60: Refactors the same code and inline-code handling paths.
  • letmutex/htmd#69: Changes whitespace trimming used by inline-code handling.
  • letmutex/htmd#75: Modifies inline-code backtick delimiter handling in the same code path.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is clearly related to the PR and summarizes the main goal of fixing Markdown conversion edge cases.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/parsing-correctness

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.

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

🤖 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.

Inline comments:
In `@src/element_handler/code.rs`:
- Around line 128-132: Update the preformatted inline-code handling around the
delimiter/content construction to also add padding when content both starts and
ends with a space, while preserving the existing backtick-boundary behavior.
Ensure all-space content and other content retain their current handling, and
add a regression test covering `<code> foo </code>` so reparsing preserves both
boundary spaces.
🪄 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: d3d8b1e8-5398-45a7-9f4e-2eb4a1555edc

📥 Commits

Reviewing files that changed from the base of the PR and between 44cb9b3 and 7bbc1d7.

📒 Files selected for processing (6)
  • src/element_handler/code.rs
  • src/element_handler/img.rs
  • src/element_handler/table.rs
  • tests/basic_tests.rs
  • tests/code_tests.rs
  • tests/table_tests.rs

Comment thread src/element_handler/code.rs Resolved
@letmutex
letmutex merged commit a11c0d1 into main Jul 27, 2026
1 check passed
@letmutex
letmutex deleted the fix/parsing-correctness branch July 27, 2026 03:35
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.

1 participant