Skip to content

Comments

fix: prevent mdx block collapsing under prettier#94

Draft
tansawit wants to merge 1 commit intomainfrom
fix/mdx-prettier-block-spacing
Draft

fix: prevent mdx block collapsing under prettier#94
tansawit wants to merge 1 commit intomainfrom
fix/mdx-prettier-block-spacing

Conversation

@tansawit
Copy link
Collaborator

Summary

This PR fixes an MDX formatting regression where Prettier collapses nested block markdown inside JSX-style components such as <Tab>, <Step>, and <Accordion>. The collapse turns multiline tables, lists, and code fences into single-line content, which breaks readability and can break rendering for docs pages.

User Impact

Authors editing docs could run formatting and unintentionally damage complex MDX sections. The issue was hard to catch in review because the resulting output is still syntactically valid MDX in many cases, but semantically degraded and difficult to read.

Root Cause

In MDX component children, indented block markdown without explicit blank-line boundaries can be interpreted in a way that Prettier rewrites as inline-ish content. This behavior is inconsistent and most visible in component-heavy docs sections.

Fix

This PR keeps Prettier and adds a targeted guardrail instead of removing formatting tooling:

  • Adds a style rule explaining required blank-line boundaries for block markdown inside <Step>, <Tab>, and <Accordion>.
  • Adds an MDX spacing checker script to catch unsafe patterns.
  • Enforces the checker in pre-commit for staged MDX changes.
  • Enforces the checker in CI for PR-diff MDX files.
  • Repairs a known broken page where tables were already collapsed.

Files Changed

  • .github/workflows/prettier.yml
  • .husky/.gitignore
  • .husky/pre-commit
  • README.md
  • STYLE_GUIDE.md
  • package.json
  • resources/developer/initia-l1.mdx
  • scripts/check-mdx-jsx-block-spacing.mjs

Validation

  • npm run format:check
  • npm run lint:mdx-spacing -- resources/developer/initia-l1.mdx
  • pre-commit hook execution on commit (npm run lint:mdx-spacing -- --staged)

Notes

This PR intentionally enforces the new MDX rule on changed files (staged/PR diff) to avoid blocking merge on legacy formatting debt. A full retroactive cleanup can be done in a separate follow-up PR.

@coderabbitai
Copy link

coderabbitai bot commented Feb 22, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/mdx-prettier-block-spacing

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


Comment @coderabbitai help to get the list of available commands and usage tips.

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