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

markdown-it-auto-parnum

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

markdown-it-auto-parnum - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

11

dist/markdown-it-auto-parnum.js

@@ -1,2 +0,2 @@

/*! markdown-it-auto-parnum 1.1.0 @license MIT */(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.markdownItAutoParnum = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
/*! markdown-it-auto-parnum 1.1.1 @license MIT */(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.markdownItAutoParnum = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
'use strict'

@@ -26,4 +26,9 @@

if (this.state.tokens[i].nesting === 1) {
this.state.tokens.splice(i + 1, 0, token)
this.state.tokens[i].block = false
if (this.state.tokens[i + 1].type === 'inline') {
this.state.tokens[i + 1].children.unshift(token)
}
else {
this.state.tokens.splice(i + 1, 0, token)
this.state.tokens[i].block = false
}
}

@@ -30,0 +35,0 @@ else {

@@ -1,1 +0,1 @@

!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).markdownItAutoParnum=e()}}(function(){return function(){return function e(t,n,i){function s(r,a){if(!n[r]){if(!t[r]){var o="function"==typeof require&&require;if(!a&&o)return o(r,!0);if(l)return l(r,!0);var h=new Error("Cannot find module '"+r+"'");throw h.code="MODULE_NOT_FOUND",h}var d=n[r]={exports:{}};t[r][0].call(d.exports,function(e){return s(t[r][1][e]||e)},d,d.exports,e,t,n,i)}return n[r].exports}for(var l="function"==typeof require&&require,r=0;r<i.length;r++)s(i[r]);return s}}()({1:[function(e,t,n){"use strict";class i{constructor(e,t){this.state=e,this.options=t,this._elements=["p"],this._value=[],this._headingLevels=t.headingLevels}insertAt(e,t=!1){let n=t?this.options.headingSign:this.options.sign,i=new this.state.Token("paragraph_number","a",0);i.content=this.value,i.attrPush([this.options.sign,this.value]),i.attrPush(["id",n+this.value]),this.options.addLinks&&i.attrPush(["href",`#${n}${this.value}`]),1===this.state.tokens[e].nesting?(this.state.tokens.splice(e+1,0,i),this.state.tokens[e].block=!1):this.state.tokens.splice(e,0,i)}increment(e="p"){let t=this._elements.indexOf(e);if(t>-1)for(this._value[2*t]++;t>0;)t--,this._value[2*t]=0}addHeadingElement(e,t=!1){if("number"==typeof t)this._elements[t]=e;else for(let t=this._headingLevels;t>0;t--)if(!this._elements[t]){this._elements[t]=e;break}}set value(e){let t=[...this._value].reverse().join("").replace(/\d+/g,0).split(/(\d+)/).filter(e=>e.length);e.split(/(\d+)/).filter(e=>e.length).forEach((e,n)=>{t[n]=e}),this._value=t.reverse()}get value(){return[...this._value].reverse().join("").replace(/(?:^[0\D]+|(?:[\D]+0)+$)/,"")}set headingLevels(e){this._headingLevels=e,e++,this._elements=this._elements.filter(e=>e),this._elements.length<e&&this._elements.fill(!1,this._elements.length,e-this._elements.length),this._value="0".repeat(e).split("").join(this.options.delimiter).split(/(0)/).filter(e=>e.length)}get headingLevels(){return this._headingLevels}get elements(){return this._elements.filter(e=>e)}}t.exports=function(e,t={}){function n(e){let n=(t.numberedElements||"paragraph").replace(/(.+?)(,|$)+/g,"$1,$1_open$2").split(",").filter(e=>e),s=(t.skippedElements||"footnote_block").replace(/(.+?)(,|$)+/g,"$1_open,$1_close$2").split(",").filter(e=>e),l=t.sign=t.sign||"\xb6";t.headingSign=t.headingSign||"";let r=!1!==t.numberHeadings;t.headingLevels=void 0===t.headingLevels?1:t.headingLevels;let a=t.delimiter=t.delimiter||".";t.addLinks=void 0===t.addLinks||Boolean(t.addLinks);let o,h,d,u,p=new i(e,t),f={p:0,h1:0,h2:0,h3:0,h4:0,h5:0,h6:0},g={p:"",h1:"",h2:"",h3:"",h4:"",h5:"",h6:""},c=!0,m=0,_=!1;for(let t=0;t<e.tokens.length;t++)(n+",heading_open").indexOf(e.tokens[t].type)>-1&&(d=/^h\d$/.test(e.tokens[t].tag)?e.tokens[t].tag:"p",(o=e.tokens[t].attrGet(l))&&/\d/.test(o)&&(o=o.replace(/[0-9]+/g,"0"),g[d]||(g[d]=o,g.p.length<g[d].length&&(g.p=g[d]+a+"0"))),f[d]++);g.p&&(p.headingLevels=g.p.split(/[^0-9]+/).length-1),["h6","h5","h4","h3","h2","h1"].forEach(e=>{g[e]&&(h=g[e].split(/[^0-9]+/).length,p.addHeadingElement(e,h))}),g.p||(g.p="0".repeat(p.headingLevels+1).split("").join(a)),p.elements.length<=p.headingLevels&&["h1","h2","h3","h4","h5","h6"].some(e=>{if(f[e]>1&&(1===p.elements.length||-1===p.elements.indexOf(e)&&p.elements[p.elements.length-1]<e)&&p.addHeadingElement(e),p.elements.length>p.headingLevels)return!0}),p.headingLevels=p.elements.filter(e=>e).length-1;for(let t=0;t<e.tokens.length;++t)if(!("paragraph_number"===e.tokens[t].type||t>0&&"paragraph_number"===e.tokens[t-1].type)){switch(u=e.tokens[t],o=e.tokens[t].attrGet(l)){case null:break;case"manual":_=!0;case"stop":case"off":c=!1;case"none":case"skip":continue;case"auto":_=!1;case"on":case"start":c=!0;break;default:if(/\d/.test(o)){p.value=o,c=!0,p.insertAt(t,/^h\d$/.test(u.tag));continue}}if(0===m&&n.indexOf(u.type)>-1){if(!c)continue;if(_)continue;if(e.tokens[t+2].tag===e.tokens[t].tag&&"inline"===e.tokens[t+1].type&&1===e.tokens[t+1].children.length&&"text"===e.tokens[t+1].children[0].type&&""===e.tokens[t+1].children[0].content.trim())continue;if(u.hidden&&!["auto","on","start"].indexOf(o)>-1&&(0===t||!("list_item_open"===e.tokens[t-1].type&&["auto","on","start"].indexOf(e.tokens[t-1].attrGet(l))>-1)))continue;p.increment(),p.insertAt(t)}else 0===m&&c&&"heading_open"===u.type&&(p.increment(e.tokens[t].tag),r&&p.elements.indexOf(u.tag)>0&&p.insertAt(t,!0));s.indexOf(u.type)>-1&&(m+=u.nesting)}}e.renderer.rules.paragraph_number=function(e,t,n,i,s){return`<a${s.renderAttrs(e[t])}>${e[t].content}</a>`},e.core.ruler.__find__("autoParNum")>-1?e.core.ruler.at("autoParNum",n):e.core.ruler.push("autoParNum",n)}},{}]},{},[1])(1)});
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).markdownItAutoParnum=e()}}(function(){return function(){return function e(t,n,i){function s(r,a){if(!n[r]){if(!t[r]){var o="function"==typeof require&&require;if(!a&&o)return o(r,!0);if(l)return l(r,!0);var h=new Error("Cannot find module '"+r+"'");throw h.code="MODULE_NOT_FOUND",h}var d=n[r]={exports:{}};t[r][0].call(d.exports,function(e){return s(t[r][1][e]||e)},d,d.exports,e,t,n,i)}return n[r].exports}for(var l="function"==typeof require&&require,r=0;r<i.length;r++)s(i[r]);return s}}()({1:[function(e,t,n){"use strict";class i{constructor(e,t){this.state=e,this.options=t,this._elements=["p"],this._value=[],this._headingLevels=t.headingLevels}insertAt(e,t=!1){let n=t?this.options.headingSign:this.options.sign,i=new this.state.Token("paragraph_number","a",0);i.content=this.value,i.attrPush([this.options.sign,this.value]),i.attrPush(["id",n+this.value]),this.options.addLinks&&i.attrPush(["href",`#${n}${this.value}`]),1===this.state.tokens[e].nesting?"inline"===this.state.tokens[e+1].type?this.state.tokens[e+1].children.unshift(i):(this.state.tokens.splice(e+1,0,i),this.state.tokens[e].block=!1):this.state.tokens.splice(e,0,i)}increment(e="p"){let t=this._elements.indexOf(e);if(t>-1)for(this._value[2*t]++;t>0;)t--,this._value[2*t]=0}addHeadingElement(e,t=!1){if("number"==typeof t)this._elements[t]=e;else for(let t=this._headingLevels;t>0;t--)if(!this._elements[t]){this._elements[t]=e;break}}set value(e){let t=[...this._value].reverse().join("").replace(/\d+/g,0).split(/(\d+)/).filter(e=>e.length);e.split(/(\d+)/).filter(e=>e.length).forEach((e,n)=>{t[n]=e}),this._value=t.reverse()}get value(){return[...this._value].reverse().join("").replace(/(?:^[0\D]+|(?:[\D]+0)+$)/,"")}set headingLevels(e){this._headingLevels=e,e++,this._elements=this._elements.filter(e=>e),this._elements.length<e&&this._elements.fill(!1,this._elements.length,e-this._elements.length),this._value="0".repeat(e).split("").join(this.options.delimiter).split(/(0)/).filter(e=>e.length)}get headingLevels(){return this._headingLevels}get elements(){return this._elements.filter(e=>e)}}t.exports=function(e,t={}){function n(e){let n=(t.numberedElements||"paragraph").replace(/(.+?)(,|$)+/g,"$1,$1_open$2").split(",").filter(e=>e),s=(t.skippedElements||"footnote_block").replace(/(.+?)(,|$)+/g,"$1_open,$1_close$2").split(",").filter(e=>e),l=t.sign=t.sign||"\xb6";t.headingSign=t.headingSign||"";let r=!1!==t.numberHeadings;t.headingLevels=void 0===t.headingLevels?1:t.headingLevels;let a=t.delimiter=t.delimiter||".";t.addLinks=void 0===t.addLinks||Boolean(t.addLinks);let o,h,d,u,p=new i(e,t),f={p:0,h1:0,h2:0,h3:0,h4:0,h5:0,h6:0},g={p:"",h1:"",h2:"",h3:"",h4:"",h5:"",h6:""},c=!0,m=0,_=!1;for(let t=0;t<e.tokens.length;t++)(n+",heading_open").indexOf(e.tokens[t].type)>-1&&(d=/^h\d$/.test(e.tokens[t].tag)?e.tokens[t].tag:"p",(o=e.tokens[t].attrGet(l))&&/\d/.test(o)&&(o=o.replace(/[0-9]+/g,"0"),g[d]||(g[d]=o,g.p.length<g[d].length&&(g.p=g[d]+a+"0"))),f[d]++);g.p&&(p.headingLevels=g.p.split(/[^0-9]+/).length-1),["h6","h5","h4","h3","h2","h1"].forEach(e=>{g[e]&&(h=g[e].split(/[^0-9]+/).length,p.addHeadingElement(e,h))}),g.p||(g.p="0".repeat(p.headingLevels+1).split("").join(a)),p.elements.length<=p.headingLevels&&["h1","h2","h3","h4","h5","h6"].some(e=>{if(f[e]>1&&(1===p.elements.length||-1===p.elements.indexOf(e)&&p.elements[p.elements.length-1]<e)&&p.addHeadingElement(e),p.elements.length>p.headingLevels)return!0}),p.headingLevels=p.elements.filter(e=>e).length-1;for(let t=0;t<e.tokens.length;++t)if(!("paragraph_number"===e.tokens[t].type||t>0&&"paragraph_number"===e.tokens[t-1].type)){switch(u=e.tokens[t],o=e.tokens[t].attrGet(l)){case null:break;case"manual":_=!0;case"stop":case"off":c=!1;case"none":case"skip":continue;case"auto":_=!1;case"on":case"start":c=!0;break;default:if(/\d/.test(o)){p.value=o,c=!0,p.insertAt(t,/^h\d$/.test(u.tag));continue}}if(0===m&&n.indexOf(u.type)>-1){if(!c)continue;if(_)continue;if(e.tokens[t+2].tag===e.tokens[t].tag&&"inline"===e.tokens[t+1].type&&1===e.tokens[t+1].children.length&&"text"===e.tokens[t+1].children[0].type&&""===e.tokens[t+1].children[0].content.trim())continue;if(u.hidden&&!["auto","on","start"].indexOf(o)>-1&&(0===t||!("list_item_open"===e.tokens[t-1].type&&["auto","on","start"].indexOf(e.tokens[t-1].attrGet(l))>-1)))continue;p.increment(),p.insertAt(t)}else 0===m&&c&&"heading_open"===u.type&&(p.increment(e.tokens[t].tag),r&&p.elements.indexOf(u.tag)>0&&p.insertAt(t,!0));s.indexOf(u.type)>-1&&(m+=u.nesting)}}e.renderer.rules.paragraph_number=function(e,t,n,i,s){return`<a${s.renderAttrs(e[t])}>${e[t].content}</a>`},e.core.ruler.__find__("autoParNum")>-1?e.core.ruler.at("autoParNum",n):e.core.ruler.push("autoParNum",n)}},{}]},{},[1])(1)});

@@ -25,4 +25,9 @@ 'use strict'

if (this.state.tokens[i].nesting === 1) {
this.state.tokens.splice(i + 1, 0, token)
this.state.tokens[i].block = false
if (this.state.tokens[i + 1].type === 'inline') {
this.state.tokens[i + 1].children.unshift(token)
}
else {
this.state.tokens.splice(i + 1, 0, token)
this.state.tokens[i].block = false
}
}

@@ -29,0 +34,0 @@ else {

{
"name": "markdown-it-auto-parnum",
"version": "1.1.0",
"version": "1.1.1",
"description": "A markdown-it plugin for automatic paragraph numbering.",

@@ -5,0 +5,0 @@ "main": "index.js",

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