New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

gitbook-plugin-etoc

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gitbook-plugin-etoc - npm Package Compare versions

Comparing version 1.2.0 to 1.2.1

8

index.js

@@ -23,2 +23,3 @@ var toc = require('markdown-toc');

if (_notoc && (!_existstoc)) return page;
var _h2lb = this.config.get('pluginsConfig.etoc.h2lb') || 3;

@@ -28,7 +29,8 @@ var _mindepth = this.config.get('pluginsConfig.etoc.mindepth') || 3;

if (_mindepth > _maxdepth) {
console.error("!!!mindepth should be no more than maxdepth");
console.error("!!!mindepth should be less equal than than maxdepth");
return page;
}
var re = new RegExp('^#{' + _mindepth + '}[^#]', 'm');
if (!re.test(page.content)) return page;
var _h2num = (page.content.match(/^##[^#]/gm) || []).length;
if (!(re.test(page.content) || (_h2num >= _h2lb))) return page;

@@ -42,3 +44,3 @@ var _header = this.config.get('pluginsConfig.etoc.header') || 1;

// markdown-toc do not pass options to generate,
// markdown-toc does not pass options to generate,
// we should escape <!-- toc --> not beginning with whitespace

@@ -45,0 +47,0 @@ page.content = page.content.replace(/^(\S.*)<!-- toc -->(.*)$/m, '$1<!-- rawtoc -->$2');

@@ -5,3 +5,3 @@ {

"main": "index.js",
"version": "1.2.0",
"version": "1.2.1",
"engines": {

@@ -40,2 +40,7 @@ "gitbook": "*"

},
"h2lb": {
"type": "number",
"description": "Lower bound of header 2",
"default": 3
},
"notoc": {

@@ -42,0 +47,0 @@ "type": "boolean",

@@ -24,3 +24,8 @@ # gitbook-plugin-etoc

It will add toc automatically if the markdown page has `###` header3(mindepth required to generate toc), and the maxdepth of toc is `####` header4 by default. You can also change the default parameter such as:
It will add toc automatically if the markdown page meets following requirements.
- `###` header3 - `mindepth` required to generate toc
- `##` number of header2 greater or equal than lower bound(3 by default, controled by `h2lb`)
The maxdepth of toc is `####` header4 by default. You can also change the default parameter such as:
```

@@ -33,2 +38,3 @@ {

"etoc": {
"h2lb": 3,
"mindepth": 3,

@@ -42,24 +48,3 @@ "maxdepth": 4,

The configuration json schema is shown as following:
```
"gitbook": {
"properties": {
"mindepth": {
"type": "number",
"description": "minimal heading level required to generate toc",
"default": 3
},
"maxdepth": {
"type": "number",
"description": "maximal heading level to generate toc",
"default": 4
},
"notoc": {
"type": "boolean",
"description": "whether to generate toc automatically",
"default": false
}
}
}
```
The configuration json schema can be found in [gitbook-plugin-etoc/package.json](https://github.com/billryan/gitbook-plugin-etoc/blob/master/package.json)

@@ -66,0 +51,0 @@ ## LICENSE

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