whitespace-se / storybook-addon-html

A Storybook addon that extracts and displays compiled syntax-highlighted HTML
Other
95 stars 44 forks source link

Remove Lit HTML comments by adjusting regex #64 #66

Closed yannickoo closed 1 year ago

yannickoo commented 2 years ago

This PR adjusts the regex so all HTML comments will be replaced.

Screenshot 2022-01-19 at 00 58 26
jeanfredrik commented 2 years ago

Thanks for the PR, but can you please add another parameter for this? removeEmptyComments doesn’t make sense since they are not empty. My suggestion would be to add a parameter called removeComments which can take true to remove all comments or a regular expression to remove just the once you want that match it:

// .storybook/preview.js

export const parameters = {
  // ...
  html: {
    removeComments: /^\$lit\$.*|\s*/ // This removes Lit comments and empty comments.
  },
};

Then we can deprecate removeEmptyComments.

dgonzalezr commented 2 years ago

Thanks for the PR, but can you please add another parameter for this? removeEmptyComments doesn’t make sense since they are not empty. My suggestion would be to add a parameter called removeComments which can take true to remove all comments or a regular expression to remove just the once you want that match it:

// .storybook/preview.js

export const parameters = {
  // ...
  html: {
    removeComments: /^\$lit\$.*|\s*/ // This removes Lit comments and empty comments.
  },
};

Then we can deprecate removeEmptyComments.

@jeanfredrik I have created PR #73 providing the changes recommended in your comment.