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

remark-toc

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remark-toc

Generate a Table of Contents (TOC) for Markdown files

  • 3.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
107K
decreased by-24.25%
Maintainers
1
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 13 Jun 2016

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