Skip to content

Commit de40da6

Browse files
authored
Merge pull request #25675 from storybookjs/docs-mdx-3
Docs: Remove mentions of MDX 2
2 parents 4e1f962 + 9a78132 commit de40da6

File tree

3 files changed

+35
-71
lines changed

3 files changed

+35
-71
lines changed

docs/faq.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Here are some answers to frequently asked questions. If you have a question, you
2121
- [I see a "No Preview" error with a Storybook production build](#i-see-a-no-preview-error-with-a-storybook-production-build)
2222
- [Can I use Storybook with Vue 3?](#can-i-use-storybook-with-vue-3)
2323
- [Why aren't my code blocks highlighted with Storybook MDX](#why-arent-my-code-blocks-highlighted-with-storybook-mdx)
24-
- [Why aren't my MDX 2 stories working in Storybook?](#why-arent-my-mdx-2-stories-working-in-storybook)
24+
- [Why aren't my MDX stories working in Storybook?](#why-arent-my-mdx-stories-working-in-storybook)
2525
- [Why are my mocked GraphQL queries failing with Storybook's MSW addon?](#why-are-my-mocked-graphql-queries-failing-with-storybooks-msw-addon)
2626
- [Can I use other GraphQL providers with Storybook's MSW addon?](#can-i-use-other-graphql-providers-with-storybooks-msw-addon)
2727
- [Can I mock GraphQL mutations with Storybook's MSW addon?](#can-i-mock-graphql-mutations-with-storybooks-msw-addon)
@@ -371,9 +371,9 @@ Yes, with the release of version 6.2, Storybook now includes support for Vue 3.
371371

372372
Out of the box, Storybook provides syntax highlighting for a set of languages (e.g., Javascript, Markdown, CSS, HTML, Typescript, GraphQL) you can use with your code blocks. Currently, there's a known limitation when you try and register a custom language to get syntax highlighting. We're working on a fix for this And will update this section once it's available.
373373
374-
## Why aren't my MDX 2 stories working in Storybook?
374+
## Why aren't my MDX stories working in Storybook?
375375

376-
MDX 2 introduced some changes to how the code is rendered. For example, if you enabled it in your Storybook and you have the following code block:
376+
MDX can be picky about how your code is formatted with line breaks. This is especially true with code blocks. For example, this will break:
377377

378378
```
379379
<style>{`
@@ -388,7 +388,7 @@ MDX 2 introduced some changes to how the code is rendered. For example, if you e
388388
389389
```
390390

391-
You'll need to update it to make it compatible with MDX 2.
391+
But this will work:
392392

393393
```
394394
<style>

docs/writing-docs/autodocs.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,9 @@ Out of the box, Storybook has a set of components that you can use to customize
230230

231231
<Callout variant="info" icon="💡">
232232

233-
This is not a Storybook issue but a breaking change introduced with MDX 2. For more information on this and other breaking changes, see our [MDX documentation](./mdx.md#breaking-changes).
233+
This is not a Storybook issue but a detail of how MDX works. From their [migration guide](https://mdxjs.com/migrating/v2/#update-mdx-content):
234+
235+
“We now ‘sandbox’ components, for lack of a better name. It means that when you pass a component for h1, it does get used for `# hi` but not for `<h1>hi</h1>`
234236

235237
</Callout>
236238

docs/writing-docs/mdx.md

+28-66
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ The `Meta` block defines where the document will be placed in the sidebar. In th
121121

122122
<!-- prettier-ignore-end -->
123123

124-
MDX2 supports standard markdown ([”commonmark”](https://commonmark.org/)) by default and can be extended to support [GitHub-flavored markdown (GFM)](https://github.github.com/gfm) and other extensions (see [Breaking changes](#breaking-changes), below).
124+
MDX supports standard markdown ([”commonmark”](https://commonmark.org/)) by default and can be extended to support [GitHub-flavored markdown (GFM)](https://github.github.com/gfm) and other extensions (see [Breaking changes](#breaking-changes), below).
125125

126126
<!-- prettier-ignore-start -->
127127

@@ -151,70 +151,7 @@ In addition to Doc Blocks, MDX can incorporate arbitrary React components, makin
151151

152152
### Known limitations
153153

154-
While MDX2 supports a variety of runtimes ([React](https://mdxjs.com/packages/react/), [Preact](https://mdxjs.com/packages/preact/), [Vue](https://mdxjs.com/packages/vue/)), Storybook’s implementation is React-only. That means your documentation is rendered in React, while your stories render in the runtime of your choice (React, Vue, Angular, Web Components, Svelte, etc.).
155-
156-
## Breaking changes
157-
158-
There are many breaking changes if you move from MDX 1 to version 2. As far as we know, all of these are due to changes in the MDX library itself rather than changes to Storybook’s usage. Nevertheless, as an MDX user, you will probably need to update your MDX files as part of the upgrade. MDX has published its own [Migration guide](https://mdxjs.com/migrating/v2/#update-mdx-files). Here, we try to summarize some of the fundamental changes for Storybook users.
159-
160-
### Custom components apply differently
161-
162-
From the MDX migration guide:
163-
164-
> We now “sandbox” components, for lack of a better name. It means that when you pass a component for `h1`, it does get used for `# hi` but not for `<h1>hi</h1>`
165-
166-
This means that the first heading in the following example gets replaced, whereas the second does not. It may not sound like a significant change, but in practice, it is highly disruptive and manifests itself in various ways. Unfortunately, this cannot be automatically converted in a safe way.
167-
168-
<!-- prettier-ignore-start -->
169-
170-
```md
171-
# Some heading
172-
173-
<h1>another heading</h1>
174-
```
175-
176-
<!-- prettier-ignore-end -->
177-
178-
### Lack of GitHub Flavored Markdown (GFM)
179-
180-
Also, from the MDX migration guide:
181-
182-
> We turned off GFM features in MDX by default. GFM extends CommonMark to add autolink literals, footnotes, strikethrough, tables, and task lists. If you do want these features, you can use a plugin. How to do so is described in [our guide on GFM](https://mdxjs.com/guides/gfm/).
183-
184-
In Storybook, you can apply MDX options, including plugins, in the main configuration file:
185-
186-
<!-- prettier-ignore-start -->
187-
188-
<CodeSnippets
189-
paths={[
190-
'common/storybook-main-config-remark-options.js.mdx',
191-
'common/storybook-main-config-remark-options.ts.mdx',
192-
]}
193-
/>
194-
195-
<!-- prettier-ignore-end -->
196-
197-
<Callout variant="info" icon="💡">
198-
199-
The [`remark-gfm`](https://github.com/remarkjs/remark-gfm) package isn't provided by default during migration. We recommend installing it as a development dependency if you use its features.
200-
201-
</Callout>
202-
203-
### Automigration
204-
205-
To help you transition to the new version, we've created a migration helper in our CLI. We recommend using it and reaching out using the default communication channels (e.g., [GitHub discussions](https://github.com/storybookjs/storybook/discussions/new?category=help)) for problems you encounter.
206-
207-
<!-- prettier-ignore-start -->
208-
209-
<CodeSnippets
210-
paths={[
211-
'common/storybook-automigration-mdx-legacy.npm.mdx',
212-
'common/storybook-automigration-mdx-legacy.pnpm.mdx',
213-
'common/storybook-automigration-mdx-legacy.yarn.mdx',
214-
]}
215-
/>
216-
217-
<!-- prettier-ignore-end -->
154+
While MDX supports a variety of runtimes ([React](https://mdxjs.com/packages/react/), [Preact](https://mdxjs.com/packages/preact/), [Vue](https://mdxjs.com/packages/vue/)), Storybook’s implementation is React-only. That means your documentation is rendered in React, while your stories render in the runtime of your choice (React, Vue, Angular, Web Components, Svelte, etc.).
218155

219156
## Setup custom documentation
220157

@@ -386,9 +323,34 @@ By applying this pattern with the Controls addon, all anchors will be ignored in
386323

387324
## Troubleshooting
388325

326+
### Markdown tables aren't rendering correctly
327+
328+
As of MDX 2, GFM is no longer included by default:
329+
330+
“We turned off GFM features in MDX by default. GFM extends CommonMark to add autolink literals, footnotes, strikethrough, tables, and task lists. If you do want these features, you can use a plugin. How to do so is described in [our guide on GFM](https://mdxjs.com/guides/gfm/).”
331+
332+
In Storybook, you can apply MDX options, including plugins, in the main configuration file:
333+
334+
<!-- prettier-ignore-start -->
335+
336+
<CodeSnippets
337+
paths={[
338+
'common/storybook-main-config-remark-options.js.mdx',
339+
'common/storybook-main-config-remark-options.ts.mdx',
340+
]}
341+
/>
342+
343+
<!-- prettier-ignore-end -->
344+
345+
<Callout variant="info" icon="💡">
346+
347+
The [`remark-gfm`](https://github.com/remarkjs/remark-gfm) package isn't provided by default during migration. We recommend installing it as a development dependency if you use its features.
348+
349+
</Callout>
350+
389351
### The MDX documentation doesn't render in my environment
390352

391-
As Storybook relies on the latest version of [MDX](https://mdxjs.com/) to render documentation, some technical limitations may prevent you from migrating to this version. If that's the case, we've prepared a set of instructions to help you transition to this new version.
353+
As Storybook relies on [MDX 3](https://mdxjs.com/) to render documentation, some technical limitations may prevent you from migrating to this version. If that's the case, we've prepared a set of instructions to help you transition to this new version.
392354

393355
#### Storybook doesn't create documentation for my component stories
394356

0 commit comments

Comments
 (0)