Skip to content

fix(markdown): widen details regex + pad fence with blank lines#622

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

fix(markdown): widen details regex + pad fence with blank lines#622
rainxchzed merged 1 commit into
mainfrom
fix/markdown-details-regex

Conversation

@rainxchzed
Copy link
Copy Markdown
Member

@rainxchzed rainxchzed commented May 16, 2026

Details collapsible from PR #621 only matched when `

` and `` had nothing but whitespace between them. Many READMEs (incl. gkd.li-style) put markup or text in between (newlines plus stripped `
` remnants from earlier passes), so the regex skipped them and the fallback `` → `bold` ran instead — summary turned into a bold heading and body rendered inline expanded.

Fix:

  • Gap between tags widened from `\s*` to `.*?` with DOT_MATCHES_ALL so anything in between matches lazily.
  • Output padded with `\n\n` before and after the fence so intellij-markdown's parser sees a proper block fence, not inline backticks.

Test plan

  • Compile clean
  • Device: open gkd.li-style README — verify `
    Details` renders as collapsed tap-to-expand card.

Summary by CodeRabbit

  • Bug Fixes

    • Improved processing of collapsible content blocks in markdown to ensure consistent and reliable rendering.
  • Refactor

    • Enhanced pattern matching and output formatting for collapsible content elements.

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: e02404cd-9149-47f1-972f-f0f67fae2d74

📥 Commits

Reviewing files that changed from the base of the PR and between bf2271a and cc3bd09.

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

Walkthrough

The PR updates the HTML <details><summary> block conversion in preprocessMarkdown.kt. The regex now uses a more permissive pattern to handle attributes and content between tags, the generated fenced block includes blank lines for proper Markdown separation, and the documentation comment is corrected to reference URL-encoding instead of base64.

Changes

Details/Summary HTML Conversion

Layer / File(s) Summary
HTML details to Markdown fenced block conversion
feature/details/data/src/commonMain/kotlin/zed/rainxch/details/data/utils/preprocessMarkdown.kt
The regex pattern for matching <details><summary> tags is changed to <details\b[^>]*?>.*?<summary...> to allow attributes and intervening content. The replacement string is updated to add blank lines around the ghs-details fenced block output. The inline comment describing the summary encoding is updated from base64 language to % URL-encoding language to match the encodeDetailsSummary function.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • OpenHub-Store/GitHub-Store#617: Modifies the same preprocessMarkdown function to add emoji shortcode rendering, extending the HTML-to-Markdown conversion pipeline.

Poem

A rabbit's details unfold with care,
Where summaries dance through the air,
Blank lines now frame each precious block,
URL-encoded, tick-tock,
Markdown flows, precise and fair! 🐰✨

✨ 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-regex

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 5191128 into main May 16, 2026
1 check was pending
@rainxchzed rainxchzed deleted the fix/markdown-details-regex branch May 16, 2026 16:18
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