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

Remove linebreaks in notes text when it are html elements #3731

Merged
merged 2 commits into from
Jun 8, 2018

Conversation

Keraito
Copy link
Contributor

@Keraito Keraito commented Jun 7, 2018

Issue: Fixes #3724

When the user adds a markdown table to the notes addon, a lot of linebreaks will be created. This is caused at https://github.com/storybooks/storybook/blob/master/addons/notes/src/register.js#L48. The table creates a string of HTML elements, with each of them proceeded by a \n. All of them thus get extended with a <br />.

What I did

Unfortunately, there is no negative lookbehind in js, so instead I added a regex before the existing one to filter out any existing linebreaks if they are immediatly after a HTML element. The detection of HTML elements could be more detailled, if that's prefered.

How to test

Added a new story.

@Keraito Keraito added bug patch:yes Bugfix & documentation PR that need to be picked to main branch addon: notes labels Jun 7, 2018
@Hypnosphi Hypnosphi merged commit aea6f48 into storybookjs:master Jun 8, 2018
@rapheld
Copy link

rapheld commented Jun 8, 2018

Thanks for the fast turn-around on this!

@Hypnosphi Hypnosphi added the patch:done Patch/release PRs already cherry-picked to main/release branch label Jun 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addon: notes bug patch:done Patch/release PRs already cherry-picked to main/release branch patch:yes Bugfix & documentation PR that need to be picked to main branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants