react-markdown-heading
TypeScript icon, indicating that this package has built-in type declarations

1.6.0 • Public • Published

react-markdown-heading

Render markdown table of contents as React component.

npm version install size minified size minzipped size codecov

Install

npm install react-markdown-heading

How to Use

import React from 'react'
import ReactDOM from 'react-dom'
import ReactMarkdownHeading from 'react-markdown-heading'

const markdown = '## h2\n### h3\n#### h4\n### h3\n# h1\n### h3'

render(
  <ReactMarkdownHeading
    markdown={markdown}
    hyperlink={true}
    onChangeHeading={(headingList) => {
      console.log(headingList)
    }}
    liClassName="li"
    activeAnchorClassName="activeAnchor"
  />,
  document.getElementById('root')
)

screen shot

Option

  • markdown - string, The Markdown source to parse (required)
  • ulClassName - string, Class name of the ul tag (optional)
  • liClassName - string, Class name of the li tag (optional)
  • anchorClassName - string, Class name of the anchor tag (optional)
  • hyperlink - boolean, Add hyperlink to text (default false)
  • blankSpaceReplaceText - string, Replace blank space in hyperlink to this (default -)
  • headingDepth - 1 | 2 | 3 | 4 | 5 | 6, Depth of heading to display (default 6)
  • hyperLinkPrefix - string, Hyperlink prefix (default empty)
  • onChangeHeading - (headingList: HeadingType[]) => void, Change event handler (optional)
  • activeHeading - HeadingType[], Designate active heading list (optional)
  • activeLiClassName - string, Class name of the active li tag (optional)
  • activeAnchorClassName - string, Class name of the active anchor tag (optional)

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.6.040latest

Version History

VersionDownloads (Last 7 Days)Published
1.6.040
1.5.00
1.4.01
1.3.00
1.2.00
1.1.37
1.1.25
1.1.10
1.1.00
1.0.11
1.0.00
0.8.20
0.8.11
0.8.00
0.7.43
0.7.30
0.7.20
0.7.11
0.7.00
0.7.0-00
0.6.20
0.6.11
0.6.00
0.6.0-30
0.6.0-20
0.6.0-10
0.5.03
0.5.0-beta.00
0.4.00
0.3.30
0.3.20
0.3.10
0.3.03
0.2.30
0.2.20
0.2.10
0.2.00
0.1.00

Package Sidebar

Install

npm i react-markdown-heading

Weekly Downloads

66

Version

1.6.0

License

MIT

Unpacked Size

16 kB

Total Files

13

Last publish

Collaborators

  • kyoncy