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

tocbot

Package Overview
Dependencies
Maintainers
1
Versions
116
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tocbot

Generate a table of contents based on the heading structure of a html document.

  • 3.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.6M
decreased by-21.59%
Maintainers
1
Weekly downloads
 
Created

What is tocbot?

The tocbot npm package is designed to generate a table of contents (TOC) based on the headings in a given HTML document. It automatically creates a TOC that can be styled and configured to enhance navigation within long documents, making it easier for users to jump to different sections.

What are tocbot's main functionalities?

Generate TOC

This feature allows you to generate a table of contents by specifying the selectors for the TOC container, the content where the headings are located, and the headings to be included in the TOC.

tocbot.init({
  tocSelector: '.js-toc',
  contentSelector: '.js-toc-content',
  headingSelector: 'h1, h2, h3'
});

Customize TOC Styling

This feature allows you to customize the classes applied to the TOC links, active links, list, and list items, enabling you to style the TOC to match your site's design.

tocbot.init({
  tocSelector: '.js-toc',
  contentSelector: '.js-toc-content',
  headingSelector: 'h1, h2, h3',
  linkClass: 'toc-link',
  activeLinkClass: 'is-active-link',
  listClass: 'toc-list',
  listItemClass: 'toc-list-item'
});

Smooth Scrolling

This feature enables smooth scrolling when a user clicks on a TOC link, providing a better user experience.

tocbot.init({
  tocSelector: '.js-toc',
  contentSelector: '.js-toc-content',
  headingSelector: 'h1, h2, h3',
  scrollSmooth: true
});

Collapse Sub-Headings

This feature allows you to specify the depth of headings that should be collapsible, helping to keep the TOC concise and focused on higher-level headings.

tocbot.init({
  tocSelector: '.js-toc',
  contentSelector: '.js-toc-content',
  headingSelector: 'h1, h2, h3',
  collapseDepth: 3
});

Other packages similar to tocbot

Keywords

FAQs

Package last updated on 16 May 2017

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