
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

npm install --save react-toc
or
yarn add react-toc
Import Toc from the package and pass props to it. As for now, markdownText is the only required prop.
import React from "react";
import Toc from "react-toc";
const Example = () => {
const yourMarkdownText = "# test \n your markdown Content # test2\n";
return <Toc markdownText={yourMarkdownText} />;
};
export default Example;
| Name | Type | Description |
|---|---|---|
markdownText | string | Required The markdown text you want to creat a TOC from. |
titleLimit | number | The maximum length of each title in the TOC. |
highestHeadingLevel | number | The highest level of headings you want to extract from the given markdownText. |
lowestHeadingLevel | number | The lowest level of headings you want to extract from the given markdownText. |
className | strig | Your custom className. |
type | "deafult" or"raw" | The type of a TOC you want to use. |
customMatchers | { [key: string]: string } | The matchers you want to use to replace the letters with. |
Pass className like the code below.
import React from "react";
import Toc from "react-toc";
const Example = () => {
const yourMarkdownText = "# test \n your markdown Content # test2\n";
return <Toc markdownText={yourMarkdownText} className={"customClassName"} />;
};
export default Example;
Now you can style your custom class just like the code below.
.customClassName {
border: solid 1px;
}
.customClassName > li {
padding-bottom: 10px;
}
You can use the customMatchers prop to replace letters in your toc.
For instance, if you want to replace ? or ! with - in your list, you can simply do this.
import React from "react";
import Toc from "react-toc";
const Example = () => {
const yourMarkdownText = "# test \n your markdown Content # test2\n";
const matchers = { "[?!]": "-" }
return <Toc markdownText={yourMarkdownText} className={"customClassName"} customMatchers={matchers}/>;
};
export default Example;
You can also give more options to the customMatchers prop like the code below.
import React from "react";
import Toc from "react-toc";
const Example = () => {
const yourMarkdownText = "# test \n your markdown Content # test2\n";
const matchers = { "[?!]": "-", "\\*": "" }
return <Toc markdownText={yourMarkdownText} className={"customClassName"} customMatchers={matchers}/>;
};
export default Example;
$ yarn install
$ yarn test
$ yarn lint
$ cd demo && yarn && yarn start
FAQs
Create a table of contents from the given markdown text.
The npm package react-toc receives a total of 222 weekly downloads. As such, react-toc popularity was classified as not popular.
We found that react-toc demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.