question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Addon-Docs: Newlines in HTML MDX <Story> gives compile error

See original GitHub issue

Describe the bug

When newlines are present in a MDX story you get a compilation error.

This works:

<Story name="function" height="100px">
  {() => {
    const btn = document.createElement('button');
    btn.innerHTML = 'Hello Button';
    return btn;
  }}
</Story>

This does not:

<Story name="function" height="100px">
  {() => {
    const btn = document.createElement('button');
    btn.innerHTML = 'Hello Button';

    return btn;
  }}
</Story>

System:

  System:                                                                                β”‚+ 125 </Story>                                                                              OS: macOS 10.14.5                                                                    β”‚<MAL  +15 ~3 ᚠ component-stor…  guide.stories.mdx  utf-8[unix]   95% ☰  119/125 ㏑ :  1
    CPU: (4) x64 Intel(R) Core(TM) i5-6267U CPU @ 2.90GHz                                β”‚7 lines yanked                                                                            Binaries:                                                                              β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
    Node: 10.15.0 - ~/.nodenv/versions/10.15.0/bin/node                                  β”‚  1 const path = require('path')                                                            Yarn: 1.13.0 - /usr/local/bin/yarn                                                   β”‚  2 const MiniCssExtractPlugin = require('mini-css-extract-plugin')
    npm: 6.4.1 - ~/.nodenv/versions/10.15.0/bin/npm                                      β”‚  3 const jsonImporter = require('node-sass-json-importer')                               Browsers:                                                                              β”‚  4 const sassTypes = require('node-sass').types
    Chrome: 76.0.3809.132                                                                β”‚  5                                                                                         Firefox: 67.0.4                                                                      β”‚  6 module.exports = async ({ config, mode }) => {
    Safari: 12.1.1                                                                       β”‚  7   // Storybook tries to load svgs by url by default. We need to use an inline-loader  npmPackages:                                                                           β”‚     some times.
    @storybook/addon-a11y: ^5.2.0-beta.36 => 5.2.0-beta.36                               β”‚  8   // This augments the storybook rule to not include SVGs so we can configure it our    @storybook/addon-actions: ^5.2.0-beta.36 => 5.2.0-beta.36                            β”‚    selves below.
    @storybook/addon-backgrounds: ^5.2.0-beta.36 => 5.2.0-beta.36                        β”‚  9   // We also strip out woff/woff2 and configure how they are served separately.         @storybook/addon-docs: ^5.2.0-beta.36 => 5.2.0-beta.36                               β”‚ 10   config.module.rules = config.module.rules.map(rule => {
    @storybook/addon-knobs: ^5.2.0-beta.36 => 5.2.0-beta.36                              β”‚ 11     {                                                                                   @storybook/addon-storysource: ^5.2.0-beta.36 => 5.2.0-beta.36                        β”‚ 12       if (String(rule.test) === String(/\.(svg|ico|jpg|jpeg|png|gif|eot|otf|webp|ttf
    @storybook/addon-viewport: ^5.2.0-beta.36 => 5.2.0-beta.36                           β”‚    |woff|woff2|cur|ani|pdf)(\?.*)?$/)) {                                                   @storybook/html: ^5.2.0-beta.36 => 5.2.0-beta.36                                     β”‚ 13         return {
    @storybook/react: ^5.2.0-beta.36 => 5.2.0-beta.36

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:26
  • Comments:24 (15 by maintainers)

github_iconTop GitHub Comments

4reactions
shilmancommented, Oct 26, 2021

@micDropper it’s a breaking change, so i’m waiting until SB 7.0 to release it. However, I will try to get a prototype working ASAP so I can figure out:

  1. what migration steps are required for users, if any
  2. whether i can do an earlier release with MDXv2 in it, possibly behind a feature flag?
4reactions
shilmancommented, Jun 9, 2021

@yairEO It’s been over a year and we’re still waiting for MDX 2.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

Storybook mdx files are not displayed - Stack Overflow
In my case the problem was that I didn't want to go with Storybook's default naming convention *.stories.mdx . I tried to omit...
Read more >
Scaffolding a React Component Library with Storybook (Using ...
It tells Storybook how to render stories within the "preview" iframe, which renders components in isolation. By default, only one named exportΒ ...
Read more >
alibaba-aero/storybook-addon-docs
When you install Docs, every story gets a DocsPage . ... const createCompiler = require('@storybook/addon-docs/mdx-compiler-plugin'); module.exportsΒ ...
Read more >
@storybook/html | Yarn - Package Manager
6.5.14 (December 2, 2022). Bug Fixes. Angular: Fix "webpack_require.nmd is not a function issue" in Angular 15 #20043; CLI/React native: Fix addons templateΒ ......
Read more >
DocsPage code preview indentation is wrong. #8078 - Issuehunt
Describe the bug When creating stories for a DocsPage with an MDX file, the code preview ... ^5.2.0-rc.10 => 5.2.0-rc.11 @storybook/addon-docs: ^5.2.0-rc.11Β ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found