Skip to content

fix(packages/components/src): MDX indentation#236

Open
code-qtzl wants to merge 5 commits into
mintlify:mainfrom
code-qtzl:fix/mdx-intentations
Open

fix(packages/components/src): MDX indentation#236
code-qtzl wants to merge 5 commits into
mintlify:mainfrom
code-qtzl:fix/mdx-intentations

Conversation

@code-qtzl
Copy link
Copy Markdown

@code-qtzl code-qtzl commented May 1, 2026

Issue: #226

Summary

When CodeBlock is used inside MDX/JSX with template literals, the code content inherits the surrounding JSX indentation, causing it to render with extra leading whitespace. This fix adds a dedentCode utility that detects the minimum indentation across all non-empty lines (after the first) and strips it uniformly, so the rendered code aligns correctly regardless of nesting depth.

Two Storybook stories (MDXIndents, MDXIndentsDeeplyNested) are added to cover typical and deeply-nested JSX indentation scenarios.

MDXIndents

MDX_Indents

MDXIndentsDeeplyNested

MDX_IndentsDeeplyNested

Note

Medium Risk
Touches core code rendering/extraction used by CodeBlock/CodeGroup (whitespace normalization affects both display and copied text), which could subtly change formatting in existing docs. Other changes are minor (removing an unintended clipboard side effect and adding a TOML preset).

Overview
Fixes MDX/JSX template-literal indentation issues by routing CodeBlock/CodeGroup text extraction through getCodeString and adding a dedentCode step in utils/shiki/lib.ts, so leading whitespace from surrounding JSX nesting is stripped consistently (including for copy-to-clipboard).

Removes the side effect that copied the updated URL to the clipboard when an Accordion opens, and adds a toml snippet preset (with optional httpSnippet) to restore a missing language/icon. Also bumps @mintlify/components to 1.0.17 and updates the changelog, plus adds two Storybook stories covering MDX indentation scenarios.

Reviewed by Cursor Bugbot for commit 91e5341. Bugbot is set up for automated code reviews on this repo. Configure here.

Co-authored-by: Copilot <copilot@github.com>
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 212818e. Configure here.

Comment thread packages/components/src/utils/shiki/lib.ts
Comment thread packages/components/src/utils/shiki/lib.ts
@code-qtzl code-qtzl force-pushed the fix/mdx-intentations branch from ba3d064 to 728aecf Compare May 1, 2026 19:22
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