9.1.7 • Published 3 months ago

markdownz v9.1.7

Weekly downloads
43
License
Apache-2.0
Repository
github
Last release
3 months ago

markdownz Build Status

Markdown viewer, editor, and help components for the Zooniverse. Requires React 16.8 or higher.

Usage

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.

import { Markdown } from 'markdownz';

<Markdown>{A String of `Markdown`}</Markdown>

Debug the viewer with the debug prop:

import { Markdown } from 'markdownz';

<Markdown debug>{A String of `Markdown`}</Markdown>

Editor:

import { MarkdownEditor } from 'markdownz';

<MarkdownEditor rows={20} value="A String of `Markdown`" onChange={this.handleMarkdownChange} />

Help:

import { MarkdownHelp } from 'markdownz'

<MarkdownHelp talk={true} title={<h1>Guide to Markdown</h1>} />

Utilities:

import { utils } from 'markdownz';

const content = `
# A test document

This is a test [with a link](https://www.zooniverse.org).
`
const html = utils.getHTML({ content });
// render HTML as JSX with utils.getComponentTree
import { utils } from 'markdownz';
const html = '<p>This is a test paragraph, with <a href="https://www.zooniverse.org">a link.</a>';
const markdownChildren = utils.getComponentTree({ html });
return <div>{markdownChildren}</div>;

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;

import { useMarkdownz } from 'markdownz';

const markdownChildren = useMarkdownz({ content: 'This is some markdown', debug: true });
return <>{markdownChildren}</>;

Supported Properties

Viewer

propertydefaulteffect
childrennullMarkdown String to Render
componentsnullRehype component mappings for the parsed output
content''Markdown String to Render used if this.props.children is null
debugfalseReturn error messages, if true, for easier debugging
settings{}Rehype settings for the parsed output
tagdivHTML tag to wrap markdown content with
className''css classes for the element
projectnullPanoptes project for links
baseURI'null'Set the base URI for building links
inlinefalseToggles rendering between markdownIt.render and markdownIt.renderInline

Editor

propertydefaulteffect
name''Name for the <textarea> in the Markdown editor
value''Value of the <textarea> in the Markdown editor
placeholder''Placeholder text in the <textarea>
row5Height of the <textarea>
cols''nullWidth of <textarea>
onChangeNOOPChange listener
projectnullPanoptes project for links
baseURI'null'Set the base URI for building links
className''css classes for the element
helpTextnullString or Component for custom help text for the editor
onHelpNOOPFunction to run when help button is clicked
previewingfalseToggle the editor's preview mode

Help

propertydefaulteffect
talkfalseToggle the inclusion of Talk-specific Markdown help content
title<h1 className="markdown-editor-title">Guide to using Markdown</h1>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. Add the new version to the changelog.
  2. npm version major|minor|patch to test, build, push and publish a new version tag. https://github.com/zooniverse/markdownz/blob/a28604159282a20530c5e88625e0f4823485fa60/package.json#L17-L20
  3. Publish a new tagged release on GitHub.

License

Copyright 2015 by The Zooniverse. Licensed under the Apache Public License v2. See LICENSE for details.

9.1.7

3 months ago

9.1.6

5 months ago

9.1.5

6 months ago

8.4.1

6 months ago

8.4.0

7 months ago

8.1.0

8 months ago

8.3.0

7 months ago

8.1.2

8 months ago

8.1.1

8 months ago

9.1.1

6 months ago

9.1.0

6 months ago

9.1.4

6 months ago

9.1.3

6 months ago

9.1.2

6 months ago

8.5.0

6 months ago

8.3.2

7 months ago

8.1.4

7 months ago

8.3.1

7 months ago

8.1.3

7 months ago

8.3.3

7 months ago

8.2.0

7 months ago

9.0.0

6 months ago

8.0.7

8 months ago

8.0.6

10 months ago

8.0.5

11 months ago

8.0.4

12 months ago

8.0.1

1 year ago

8.0.3

1 year ago

8.0.2

1 year ago

7.8.4

1 year ago

7.8.3

2 years ago

7.8.6

1 year ago

7.8.5

1 year ago

7.9.0

1 year ago

8.0.0

1 year ago

7.10.2

1 year ago

7.10.0

1 year ago

7.10.1

1 year ago

7.8.2

2 years ago

7.8.0

2 years ago

7.8.1

2 years ago

7.7.2

3 years ago

7.7.1

5 years ago

7.7.0

5 years ago

7.6.6

5 years ago

7.6.5

5 years ago

7.6.4

5 years ago

7.6.3

6 years ago

7.6.2

6 years ago

7.6.1

6 years ago

7.6.0

6 years ago

7.5.0

6 years ago

7.4.2

6 years ago

7.4.1

6 years ago

7.4.0

6 years ago

7.3.1

7 years ago

7.3.0

7 years ago

7.2.1

7 years ago

7.2.0

7 years ago

7.1.0

7 years ago

7.0.1

7 years ago

7.0.0

7 years ago

6.0.0

7 years ago

5.0.0

7 years ago

4.2.0

8 years ago

4.1.6

8 years ago

4.1.5

8 years ago

4.1.4

8 years ago

4.1.3

8 years ago

4.1.2

8 years ago

4.1.1

8 years ago

4.1.0

8 years ago

4.0.4

8 years ago

4.0.3

8 years ago

4.0.2

8 years ago

4.0.1

8 years ago

3.1.4

8 years ago

4.0.0

8 years ago

3.0.3

9 years ago

3.0.2

9 years ago

3.0.1

9 years ago

3.0.0

9 years ago

2.5.1

9 years ago

2.5.0

9 years ago

2.4.0

9 years ago

2.3.0

9 years ago

2.2.0

9 years ago

2.1.0

9 years ago

2.0.1

9 years ago

2.0.0

9 years ago

1.0.4

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago