A react component that renders Stoplight flavored markdown.
npm install @stoplight/markdown-viewerA Stoplight Markdown viewer React component
- Explore the components: Storybook
- View the changelog: Releases
- Supports Stoplight markdown annotations
- MDAST-spec compliant
- Theme-able
- Render custom components
Supported in modern browsers.
``bash`markdown viewer + peer deps
yarn add @stoplight/markdown-viewer @stoplight/mosaic @stoplight/mosaic-code-viewer react react-dom
``tsx
import { DefaultSMDComponents, MarkdownViewer } from '@stoplight/markdown-viewer';
import { JSONSchemaViewer } from '@stoplight/json-schema-viewer';
const markdown =
Hi there.
``;
includeToc
parseOptions={{
components: {
// Example of overriding the default code renderer for jsonSchema blocks
code: props => {
if (props.jsonSchema) {
return
}
// Fallback to the default component mapping
const DefaultCodeViewer = DefaultSMDComponents.code;
return
},
},
}}
/>;
``
When overriding components it is often easier to do so once, globally, in the consuming application. To do so just use
the MarkdownViewerProvider component.
`tsx
import { MarkdownViewerProvider, MarkdownViewer } from '@stoplight/markdown-viewer';
const markdown = my link;
a: props => ,
p: props =>
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.