Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add automigration MDX1 HTML comments to MDX2 JSX comments #20200

Closed
Tracked by #20674
shilman opened this issue Dec 12, 2022 · 5 comments
Closed
Tracked by #20674

Add automigration MDX1 HTML comments to MDX2 JSX comments #20200

shilman opened this issue Dec 12, 2022 · 5 comments

Comments

@shilman
Copy link
Member

shilman commented Dec 12, 2022

See #18554

@ndelangen
Copy link
Member

ndelangen commented Dec 20, 2022

@shilman replacing HTML-comment with JS comments in all MDX files, should do the trick right?

We likely will have to do this with a RegExp, considering the MDX compiler actually is not able to parse the file..

  1. find all MDX files
  2. search for HTML comments globally over each file: /\<\!\-\-(.+)\-\-\>/
  3. replace each occurrence with {/* $1 */}

This seems like the best place for it:

return mdx.replace(MDX1_SCRIPT_START, '<style>\n {`').replace(MDX1_SCRIPT_END, ' `}\n</style>');

@shilman
Copy link
Member Author

shilman commented Dec 20, 2022

Yup!!

@slorber
Copy link
Contributor

slorber commented Dec 21, 2022

Docusaurus maintainer 👋 also trying to upgrade to MDX 2 facebook/docusaurus#8288

Worth taking into consideration that comments might be nested inside HTML code blocks 🤪

<!-- md comment -->

```html
<div>
  <!-- HTML comment (do not transform) -->
</div>
```

@ndelangen
Copy link
Member

@shilman
Copy link
Member Author

shilman commented Jan 13, 2023

Crikey!! I just released https://github.com/storybookjs/storybook/releases/tag/v7.0.0-beta.26 containing PR #20349 that references this issue. Upgrade today to the @next NPM tag to try it out!

npx sb@next upgrade --prerelease

Closing this issue. Please re-open if you think there's still more to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

3 participants