Socket
Socket
Sign inDemoInstall

@reapit/storybook-addon-html

Package Overview
Dependencies
95
Maintainers
2
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @reapit/storybook-addon-html

A Storybook addon that extracts and displays compiled syntax-highlighted HTML


Version published
Weekly downloads
114
increased by23.91%
Maintainers
2
Install size
47.7 MB
Created
Weekly downloads
 

Changelog

Source

5.0.1 (2022-11-11)

⚠ BREAKING CHANGES

  • Complete rewrite based on the official addon kit structure

Code Refactoring

  • Complete rewrite based on the official addon kit structure (836d4b9)

Readme

Source

Fork of original module

Forked purely to ensure Prettier is tagged at v2.2.X - a regex was introduced in Prettier v2.3.x which causes my Storybook build to fail. Full credit and thanks to the maintainers of this project.

Storybook Addon HTML

This addon for Storybook adds a tab that displays the compiled HTML for each story. It uses highlight.js for syntax highlighting.

Animated preview

Getting Started

With NPM:

npm i --save-dev @whitespace/storybook-addon-html

With Yarn:

yarn add -D @whitespace/storybook-addon-html

Register addon

// .storybook/main.js

module.exports = {
  // ...
  addons: [
    '@whitespace/storybook-addon-html',
    // ...
  ],
};

Usage

The HTML is formatted with Prettier. You can override the Prettier config (except parser and plugins) by providing an object following the Prettier API override format in the html parameter:

// .storybook/preview.js

export const parameters = {
  // ...
  html: {
    prettier: {
      tabWidth: 4,
      useTabs: false,
      htmlWhitespaceSensitivity: 'strict',
    },
  },
};

You can override the wrapper element selector used to grab the component HTML.

export const parameters = {
  html: {
    root: '#my-custom-wrapper', // default: #root
  },
};

When using Web Components, the HTML will contain empty comments, i.e. <!---->. If you want to remove these, use the removeEmptyComments parameter:

export const parameters = {
  html: {
    removeEmptyComments: true, // default: false
  },
};

You can override the showLineNumbers and wrapLines settings for the syntax highlighter by using the highlighter parameter:

export const parameters = {
  html: {
    highlighter: {
      showLineNumbers: true, // default: false
      wrapLines: false, // default: true
    },
  },
};

Supported frameworks

As of version 4.0.0 all frameworks are supported per default 🎉

Keywords

FAQs

Last updated on 19 Jul 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc