Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

remark-toc

Package Overview
Dependencies
Maintainers
2
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remark-toc

remark plugin to generate a table of contents (TOC)

  • 9.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
106K
decreased by-37.62%
Maintainers
2
Weekly downloads
 
Created

What is remark-toc?

The remark-toc package is a plugin for the remark markdown processor that automatically generates a table of contents (TOC) for markdown documents. It scans the document for headings and creates a TOC based on those headings, which can be customized and inserted at a specified location in the document.

What are remark-toc's main functionalities?

Generate TOC

This feature allows you to generate a table of contents for a markdown document. The code sample demonstrates how to use the remark-toc plugin with the remark processor to automatically generate a TOC based on the headings in the document.

const remark = require('remark');
const toc = require('remark-toc');

remark()
  .use(toc)
  .process('# Title\n## Subtitle\n### Subsubtitle', function (err, file) {
    if (err) throw err;
    console.log(String(file));
  });

Custom TOC Heading

This feature allows you to customize the heading of the generated TOC. The code sample shows how to set a custom heading 'Table of Contents' for the TOC.

const remark = require('remark');
const toc = require('remark-toc');

remark()
  .use(toc, { heading: 'Table of Contents' })
  .process('# Title\n## Subtitle\n### Subsubtitle', function (err, file) {
    if (err) throw err;
    console.log(String(file));
  });

Custom TOC Depth

This feature allows you to limit the depth of the TOC. The code sample demonstrates how to generate a TOC that includes only headings up to the second level.

const remark = require('remark');
const toc = require('remark-toc');

remark()
  .use(toc, { maxDepth: 2 })
  .process('# Title\n## Subtitle\n### Subsubtitle', function (err, file) {
    if (err) throw err;
    console.log(String(file));
  });

Other packages similar to remark-toc

Keywords

FAQs

Package last updated on 20 Sep 2023

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc