Markdown viewer and editor for the Zooniverse
npm install markdownzMarkdown viewer, editor, and help components for the Zooniverse. Requires React 16.8 or higher.
Available on npm, include as a dependency using npm install --save markdownz
This package contains three publicly accessible components: a Markdown viewer and a Markdown editor for Zooniverse-flavored Markdown, and a MarkdownHelp component.
Viewer:
Parse markdown to HTML with markdown-it, then render the result as a React component tree with rehype-react.
``jsx
import { Markdown } from 'markdownz';
}
`
Debug the viewer with the debug prop:
`jsx
import { Markdown } from 'markdownz';
}
`
Editor:
`jsx
import { MarkdownEditor } from 'markdownz';
`
Help:
`jsx
import { MarkdownHelp } from 'markdownz'
`
Utilities:
`js
import { utils } from 'markdownz';
const content =
This is a test with a link.`
const html = utils.getHTML({ content });
` This is a test paragraph, with a link.';jsx`
// render HTML as JSX with utils.getComponentTree
import { utils } from 'markdownz';
const html = '
const markdownChildren = utils.getComponentTree({ html });
return {markdownChildren};
Hooks:
The useMarkdownz hook accepts the same props as the Markdown component. It returns the parsed content as a React component tree, which can be rendered as JSX or with React.createElement;
`jsx
import { useMarkdownz } from 'markdownz';
const markdownChildren = useMarkdownz({ content: 'This is some markdown', debug: true });
return <>{markdownChildren}>;
`
| property | default | effect |
|----------|:-------:|--------|
| children | null | Markdown String to Render |null
| components | | Rehype component mappings for the parsed output |''
| content | | Markdown String to Render used if this.props.children is null |false
| debug | | Return error messages, if true, for easier debugging |{}
| settings | | Rehype settings for the parsed output |div
| tag | | HTML tag to wrap markdown content with |''
| className | | css classes for the element |null
| project | | Panoptes project for links |false
| baseURI | 'null' | Set the base URI for building links |
| inline | | Toggles rendering between markdownIt.render and markdownIt.renderInline
| property | default | effect |
|----------|:-------:|--------|
| name | '' | Name for the
| property | default | effect |
|----------|:-------:|--------|
| talk | false| Toggle the inclusion of Talk-specific Markdown help content |
| title |
| Title displayed at the top of the MarkdownHelp component |Zooniverse-Flavoured Markdown
We use markdown-it for rendering Markdown and twemoji for cross-browser emoji support.
TODO: Document custom extensions.
Contributing
See CONTRIBUTING.md
Publishing
1. Create a new branch for the new version.
2. Add the new version to the changelog with summary of changes.
3. Update package.json and package-lock.json with the new version number (manually or with
npm --no-git-tag-version version [major|minor|patch]).
4. Commit and push the changes to GitHub. Create a pull request, optionally have it reviewed, and merge it.
5. Using GitHub's web interface, create a new tag and release with the new version number and summary of changes.
6. Pull the new version of the package locally.
7. To clear any prior build (./lib), run tests, and create a fresh build, run "rm -rf lib && npm test && npm run build".
8. Run npm publish --dry-run to check that the package is ready to publish.
9. Run npm publish` to publish the new version to npm.Copyright 2015 by The Zooniverse. Licensed under the Apache Public License v2. See LICENSE for details.