Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
:book: minimal 1KB on-the-fly TOC generator
Creates a table of contents automatically in your generated markdown or any other HTML page.
Try the online editor
Of course there are already tools to generate a TOC, but they need to be executed during build time. If you convert markdown to HTML you need a build process anyway, but generation of a TOC might be another build step in your pipeline, if you don't use Jekyll with Kramdown which suports a TOC out of the box.
This library generates the TOC at runtime in the browser. If you use HTML (not generated from markdown) you can use this library as well. It helps you to avoid updating your TOC at build time completely.
Name | Type | Size, gzip |
---|---|---|
markdown-toc | Buildtime | - |
doctoc | Buildtime | - |
auto-toc.js | Runtime, minimal | 1.0k |
contents | Runtime, advanced | 23k |
TOC | Runtime, jQuery | 1.2k + jQuery |
jquery.tocify | Runtime, jQuery | 2.3k + jQuery |
NOTE This won't work for your README.md files on github.com, see here why.
This feature needs to be provided by GitHub, see here
You can use this with README.md files on your GitHub pages or any other pages, where you have control to the (sub)domain.
# My fancy library
## Installation
### Windows
### OSX
## Usage
### Basic
### Advanced
Assuming all the headings are children of a div with the class content
in your generated HTML file.
Then just add a div element with a special class and add two script tags:
# My fancy library
## Table of contents
<div class="toc-placeholder"></div>
## Installation
### Windows
### OSX
## Usage
### Basic
### Advanced
<script src="https://cdn.jsdelivr.net/auto-toc.js/0.0.6/dist.js"></script>
<script>
autoToc('.content', '.toc-placeholder');
</script>
You can either use jsdelivr to embed auto-toc.js (see example above) to your page or install it via npm:
npm i auto-toc --save
auto-toc.js is bundled as Universal Module Defition. So you can use it with CommonJS, AMD or just via the global window scope.
var autoToc = require('auto-toc')
You can also ignore headings by using the toc-ignore
class:
<h2 class="toc-ignore">Ignore this heading in the TOC</h2>
FAQs
On the fly TOC generator
The npm package auto-toc receives a total of 0 weekly downloads. As such, auto-toc popularity was classified as not popular.
We found that auto-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
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.