5.7.0 • Published 2 months ago

@stoplight/markdown-viewer v5.7.0

Weekly downloads
1,151
License
Apache-2.0
Repository
github
Last release
2 months ago

@stoplight/markdown-viewer

A Stoplight Markdown viewer React component

Features

Installation

Supported in modern browsers.

# markdown viewer + peer deps
yarn add @stoplight/markdown-viewer @stoplight/mosaic @stoplight/mosaic-code-viewer react react-dom

Basic Usage

import { DefaultSMDComponents, MarkdownViewer } from '@stoplight/markdown-viewer';
import { JSONSchemaViewer } from '@stoplight/json-schema-viewer';

const markdown = `
### Welcome

Hi there.
```;

<MarkdownViewer
  markdown={markdown}
  includeToc
  parseOptions={{
    components: {
      // Example of overriding the default code renderer for jsonSchema blocks
      code: props => {
        if (props.jsonSchema) {
          return <JSONSchemaViewer value={JSON.parse(props.children)} />;
        }

        // Fallback to the default component mapping
        const DefaultCodeViewer = DefaultSMDComponents.code;
        return <DefaultCodeViewer {...props} />;
      },
    },
  }}
/>;

MarkdownViewerProvider

When overriding components it is often easier to do so once, globally, in the consuming application. To do so just use the MarkdownViewerProvider component.

import { MarkdownViewerProvider, MarkdownViewer } from '@stoplight/markdown-viewer';

const markdown = `[my link](http://hello.com)`;

<MarkdownViewerProvider
  components={{
    a: props => <a {...props} data-test="CUSTOM-1" />,
    p: props => <p {...props} data-test="CUSTOM-1" />,
  }}
>
  // somewhere deeper in your application... the custom a and p components will be used when rendering the markdown
  <MarkdownViewer markdown={markdown} />
</MarkdownViewerProvider>;

More examples can be find in the Storybook stories.

Contributing

  1. Clone repo.
  2. Create / checkout feature/{name}, chore/{name}, or fix/{name} branch.
  3. Install deps: yarn.
  4. Make your changes.
  5. Run tests: yarn test.prod.
  6. Stage relevant files to git.
  7. Commit: yarn commit. NOTE: Commits that don't follow the conventional format will be rejected. yarn commit creates this format for you, or you can put it together manually and then do a regular git commit.
  8. Push: git push.
  9. Open PR targeting the develop branch.
5.7.0

2 months ago

5.6.0

1 year ago

5.5.1

2 years ago

5.5.0

2 years ago

5.4.7

2 years ago

5.4.6

2 years ago

5.4.5

2 years ago

5.4.4

2 years ago

5.4.3

2 years ago

5.4.2

2 years ago

5.4.1

2 years ago

5.4.0

2 years ago

5.3.3

3 years ago

5.3.2

3 years ago

5.3.1

3 years ago

5.3.0

3 years ago

5.2.1

3 years ago

5.2.0

3 years ago

5.1.3

3 years ago

5.1.2

3 years ago

5.1.1

3 years ago

5.1.0

3 years ago

5.0.0

3 years ago

5.0.0-beta.8

3 years ago

5.0.0-beta.7

3 years ago

5.0.0-beta.6

3 years ago

5.0.0-beta.5

3 years ago

5.0.0-beta.4

3 years ago

5.0.0-beta.2

3 years ago

5.0.0-beta.3

3 years ago

5.0.0-beta.1

3 years ago

4.3.4

3 years ago

4.3.3

3 years ago

4.3.2

3 years ago

4.3.1

3 years ago

4.3.0

4 years ago

4.2.3

4 years ago

4.2.2

4 years ago

4.2.1

4 years ago

4.2.0

4 years ago

4.1.2

4 years ago

4.1.1

4 years ago

4.1.0

4 years ago

4.0.2

4 years ago

4.0.1

4 years ago

4.0.0

4 years ago

3.8.1

4 years ago

3.8.0

4 years ago

3.7.2

4 years ago

3.7.1

4 years ago

3.7.0

5 years ago

3.6.0

5 years ago

3.5.6

5 years ago

3.5.5

5 years ago

3.5.4

5 years ago

3.5.3

5 years ago

3.5.2

5 years ago

3.5.1

5 years ago

3.5.0

5 years ago

3.4.0

5 years ago

3.3.1

5 years ago

3.3.0

5 years ago

3.2.0

5 years ago

3.1.1

5 years ago

3.1.0

5 years ago

3.0.5

5 years ago

3.0.4

5 years ago

3.0.3

5 years ago

3.0.2

5 years ago

3.0.1

5 years ago

3.0.0

5 years ago

3.0.0-beta.4

5 years ago

3.0.0-beta.3

5 years ago

3.0.0-beta.2

5 years ago

3.0.0-beta.1

5 years ago

2.0.0

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago