Research
Security News
Malicious npm Package Typosquats react-login-page to Deploy Keylogger
Socket researchers unpack a typosquatting package with malicious code that logs keystrokes and exfiltrates sensitive data to a remote server.
metalsmith-autotoc
Advanced tools
Readme
A metalsmith plugin to generate table of contents of a document.
This plugin generate table of contents object to document's metadata.
$ npm install metalsmith-autotoc
Default: ``
This value will be added to generated header ids as a prefix.
Default: 'h2,h3,h4,h5,h6'
A list of header selectors to search.
Source file src/index.html
:
---
autotoc: true
template: 'layout.eco'
---
<h2>aaa</h2>
<p>paragraph</p>
<h3>bbb</h3>
<p>paragraph</p>
<h3>ccc</h3>
<p>paragraph</p>
<h2>ddd</h2>
<p>paragraph</p>
Template file templates/layout.eco
:
<% renderToc = (items) => %>
<ol class="toc">
<% for item in items: %>
<li><a href="#<%= item.id %>"><%= item.text %></a>
<% if item.children.length > 0: %><%- renderToc(item.children) %><% end %>
</li>
<% end %>
</ol>
<% end %>
<% if @toc: %>
<%- renderToc(@toc) %>
<% end %>
<%- @contents %>
Build file build.js
:
var metalsmith = require('metalsmith');
var autotoc = require('metalsmith-autotoc');
var templates = require('metalsmith-templates');
metalsmith(__dirname)
.source('./src')
.destination('./dest')
.use(autotoc({selector: 'h2, h3, h4'}))
.use(templates({
engine: 'eco',
directory: './templates'
}))
.build();
Results file dest/index.html
:
<ol class="toc">
<li><a href="#aaa">aaa</a>
<ol class="toc">
<li><a href="#bbb">bbb</a></li>
<li><a href="#ccc">ccc</a></li>
</ol>
</li>
<li><a href="#ddd">ddd</a></li>
</ol>
<h2 id="aaa">aaa</h2>
<p>paragraph</p>
<h3 id="bbb">bbb</h3>
<p>paragraph</p>
<h3 id="ccc">ccc</h3>
<p>paragraph</p>
<h2 id="ddd">ddd</h2>
<p>paragraph</p>
MIT
FAQs
Unknown package
The npm package metalsmith-autotoc receives a total of 319 weekly downloads. As such, metalsmith-autotoc popularity was classified as not popular.
We found that metalsmith-autotoc 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.
Research
Security News
Socket researchers unpack a typosquatting package with malicious code that logs keystrokes and exfiltrates sensitive data to a remote server.
Security News
The JavaScript community has launched the e18e initiative to improve ecosystem performance by cleaning up dependency trees, speeding up critical parts of the ecosystem, and documenting lighter alternatives to established tools.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.