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

doctoc

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

doctoc - npm Package Compare versions

Comparing version 0.5.3 to 0.6.0

lib/get-html-headers.js

22

lib/transform.js

@@ -5,3 +5,4 @@ 'use strict';

, anchor = require('anchor-markdown-header')
, updateSection = require('update-section');
, updateSection = require('update-section')
, getHtmlHeaders = require('./get-html-headers');

@@ -29,3 +30,4 @@ var start = '<!-- START doctoc generated TOC please keep comment here to allow auto update -->\n' +

function getHashedHeaders (lines) {
var inCodeBlock = false;
var inCodeBlock = false
, lineno = 0;

@@ -39,4 +41,7 @@ // Turn all headers into '## xxx' even if they were '## xxx ##'

return lines
.map(function (x, idx) {
return { lineno: idx, line: x }
})
.filter(function (x) {
if (x.match(/^```/)) {
if (x.line.match(/^```/)) {
inCodeBlock = !inCodeBlock;

@@ -46,4 +51,4 @@ }

})
.map(function (x, index) {
var match = /^(\#{1,8})[ ]*(.+)\r?$/.exec(x);
.map(function (x) {
var match = /^(\#{1,8})[ ]*(.+)\r?$/.exec(x.line);

@@ -53,3 +58,3 @@ return match

, name : normalize(match[2])
, line : index
, line : x.lineno
}

@@ -124,3 +129,5 @@ : null;

var headers = getHashedHeaders(linesToToc).concat(getUnderlinedHeaders(linesToToc));
var headers = getHashedHeaders(linesToToc)
.concat(getUnderlinedHeaders(linesToToc))
.concat(getHtmlHeaders(linesToToc))

@@ -137,3 +144,2 @@ headers.sort(function (a, b) {

var toc =

@@ -140,0 +146,0 @@ '**Table of Contents** *generated with [DocToc](http://doctoc.herokuapp.com/)*'

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

"description": "Generates TOC for markdown files of local git repo.",
"version": "0.5.3",
"version": "0.6.0",
"repository": {

@@ -22,6 +22,7 @@ "type": "git",

"anchor-markdown-header": "~0.3.0",
"update-section": "^0.3.0"
"htmlparser2": "~3.7.1",
"update-section": "~0.3.0"
},
"devDependencies": {
"tap": "^0.4.8"
"tap": "~0.4.8"
},

@@ -28,0 +29,0 @@ "license": "MIT",

Sorry, the diff of this file is not supported yet

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