Skip to content

fix(markdown): run details normalization before HTML-to-newline passes#625

Merged
rainxchzed merged 1 commit into
mainfrom
fix/markdown-details-before-br
May 16, 2026
Merged

fix(markdown): run details normalization before HTML-to-newline passes#625
rainxchzed merged 1 commit into
mainfrom
fix/markdown-details-before-br

Conversation

@rainxchzed
Copy link
Copy Markdown
Member

@rainxchzed rainxchzed commented May 16, 2026

PR #624 still missed librepods because the `
` → `\n` and `

` → `\n\n` passes ran BEFORE the details handler. They split table rows mid-cell, so by the time details ran, the line containing `
Details` no longer had a `|` before it → table-cell context check failed → multi-line fence emitted → table broken.

Fix: move the entire `

` detect-and-flatten step into a new Phase 0.5, right after reference-link resolution and before any HTML→newline conversion. Also strip embedded `
` from the body during flatten so they don't reintroduce newlines after collapse.

Test plan

  • Compile clean
  • Device: librepods README — feature-availability table renders end-to-end (all rows), "Renaming AirPods" cell has bold inline "Note for Android" prefix.

Summary by CodeRabbit

  • Refactor
    • Optimized markdown processing for collapsible content blocks to improve formatting consistency.
    • Enhanced handling of collapsible elements in inline contexts and table cells.
    • Improved whitespace normalization for nested content within collapsible blocks.

Review Change Stack

Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rainxchzed has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 16, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 940703ea-0fa8-4f84-8df9-c59557238d42

📥 Commits

Reviewing files that changed from the base of the PR and between f00301b and e5f8199.

📒 Files selected for processing (1)
  • feature/details/data/src/commonMain/kotlin/zed/rainxch/details/data/utils/preprocessMarkdown.kt

Walkthrough

This PR refactors preprocessMarkdown.kt to relocate <details>/<summary> normalization logic to a new "Phase 0.5" pass that executes before general HTML→Markdown conversions. The new early-phase logic flattens inline and table-cell details content, and the previous later-phase implementation is removed.

Changes

Details/Summary Normalization Phase

Layer / File(s) Summary
Phase 0.5 details normalization and prior logic removal
feature/details/data/src/commonMain/kotlin/zed/rainxch/details/data/utils/preprocessMarkdown.kt
A new Phase 0.5 regex normalization flattens inline and table-cell <details> blocks by converting <br> to spaces and collapsing whitespace, emitting either summary text or **summary**: flatBody format. The superseded later-phase <details>/<summary> conversion implementation is removed.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

A rabbit hops through phases bright,
Details now normalize just right,
Flat as a table, inline with grace,
Phase 0.5 finds its proper place! 🐰✨

✨ 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/markdown-details-before-br

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.

@rainxchzed rainxchzed merged commit 6a3fdcd into main May 16, 2026
1 check was pending
@rainxchzed rainxchzed deleted the fix/markdown-details-before-br branch May 16, 2026 16:36
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