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.

DocsPage code preview indentation is wrong

See original GitHub issue

Issuehunt badges

Describe the bug When creating stories for a DocsPage with an MDX file, the code preview underneath the story seems to have the wrong indentation, even though it’s correct in the file.

To Reproduce Steps to reproduce the behavior:

  1. Create a Component.stories.mdx file
  2. Output a <Story name="default"><Preview><Component /></Preview></Story>
  3. Go to DocsPage for that component
  4. Click “Code” button to bring up code preview
  5. See wrong indentation for code preview

Expected behavior The indentation (and line breaks) would be identical to how it shows up in the MDX file.

Screenshots The code:

and how it shows up in the DocsPage <Preview>:

Code snippets If applicable, add code samples to help explain your problem.

System: Environment Info:

System: OS: macOS 10.14.6 CPU: (8) x64 Intel® Core™ i7-4870HQ CPU @ 2.50GHz Binaries: Node: 12.6.0 - /usr/local/bin/node Yarn: 1.17.3 - /usr/local/bin/yarn npm: 6.9.0 - /usr/local/bin/npm Browsers: Chrome: 76.0.3809.87 Firefox: 68.0.1 Safari: 12.1.2 npmPackages: @storybook/addon-actions: ^5.2.0-rc.10 => 5.2.0-rc.11 @storybook/addon-docs: ^5.2.0-rc.11 => 5.2.0-rc.11 @storybook/addon-links: ^5.2.0-rc.10 => 5.2.0-rc.11 @storybook/addons: ^5.2.0-rc.10 => 5.2.0-rc.11 @storybook/react: ^5.2.0-rc.10 => 5.2.0-rc.11

Additional context The same exact indentation abnormality (2nd through 2nd last lines are indented one tab too far left, and last line indented two tabs too far right) seems to happen for all my DocsPage code previews, so I figured it’s either a configuration issue somewhere on my end, or a bug with the DocsPage code preview.

Thanks!


IssueHunt Summary

Backers (Total: $20.00)

Become a backer now!

Or submit a pull request to get the deposits!

Tips

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:41
  • Comments:36 (15 by maintainers)

github_iconTop GitHub Comments

30reactions
mrtrasercommented, Jan 22, 2020

Indentation still wrong for *.mdx files in storybook v5.3.8

Source: Screenshot 2020-01-22 at 17 29 38

Result: Screenshot 2020-01-22 at 17 29 22

21reactions
frassiniercommented, Jun 22, 2021

Here is a workaround for now, by editing your preview.js

import prettier from 'prettier/standalone';
import prettierBabel from 'prettier/parser-babel';

export const parameters = {
  docs: {
    transformSource: input =>
      prettier.format(input, {
        parser: 'babel',
        plugins: [prettierBabel],
      }),
  },
};

Hope it can help!

Read more comments on GitHub >

github_iconTop Results From Across the Web

DocsPage code preview indentation is wrong. #8078 - Issuehunt
Describe the bug When creating stories for a DocsPage with an MDX file, the code preview underneath the story seems to have the...
Read more >
DocsPage - Storybook - JS.ORG
It aggregates your stories, text descriptions, docgen comments, args tables, and code examples into a single page for each component. The best practice...
Read more >
storybook code preview doesn't show the usage of slots in ...
I'm using beautify-js to format the html indentation after removing the template tags. // preview.js var beautify_html ...
Read more >
Google Docs: Using Indents and Tabs - GCF Global
A great way to draw attention to important areas within your document is to add an indent or tab. There are several ways...
Read more >
How to docs — UltraZohm 0.0.1 documentation
Sphinx takes the different RST files and builds them to the docs page. ... is useful for writing the documentation and getting a...
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