Socket
Socket
Sign inDemoInstall

markdown-it-ins

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

markdown-it-ins - npm Package Compare versions

Comparing version 3.0.1 to 4.0.0

dist/index.cjs.js

168

dist/markdown-it-ins.js

@@ -1,116 +0,94 @@

/*! markdown-it-ins 3.0.1 https://github.com/markdown-it/markdown-it-mark @license MIT */
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.markdownitIns = factory());
}(this, (function () { 'use strict';
var markdownItIns = function ins_plugin(md) {
/*! markdown-it-ins 4.0.0 https://github.com/markdown-it/markdown-it-ins @license MIT */
(function(global, factory) {
typeof exports === "object" && typeof module !== "undefined" ? module.exports = factory() : typeof define === "function" && define.amd ? define(factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self,
global.markdownitIns = factory());
})(this, (function() {
"use strict";
function ins_plugin(md) {
// Insert each marker as a separate text token, and add it to delimiter list
//
function tokenize(state, silent) {
var i, scanned, token, len, ch,
start = state.pos,
marker = state.src.charCodeAt(start);
if (silent) { return false; }
if (marker !== 0x2B/* + */) { return false; }
scanned = state.scanDelims(state.pos, true);
len = scanned.length;
ch = String.fromCharCode(marker);
if (len < 2) { return false; }
const start = state.pos;
const marker = state.src.charCodeAt(start);
if (silent) {
return false;
}
if (marker !== 43 /* + */) {
return false;
}
const scanned = state.scanDelims(state.pos, true);
let len = scanned.length;
const ch = String.fromCharCode(marker);
if (len < 2) {
return false;
}
if (len % 2) {
token = state.push('text', '', 0);
const token = state.push("text", "", 0);
token.content = ch;
len--;
}
for (i = 0; i < len; i += 2) {
token = state.push('text', '', 0);
for (let i = 0; i < len; i += 2) {
const token = state.push("text", "", 0);
token.content = ch + ch;
if (!scanned.can_open && !scanned.can_close) { continue; }
if (!scanned.can_open && !scanned.can_close) {
continue;
}
state.delimiters.push({
marker: marker,
length: 0, // disable "rule of 3" length checks meant for emphasis
jump: i / 2, // 1 delimiter = 2 characters
token: state.tokens.length - 1,
end: -1,
open: scanned.can_open,
close: scanned.can_close
length: 0,
// disable "rule of 3" length checks meant for emphasis
jump: i / 2,
// 1 delimiter = 2 characters
token: state.tokens.length - 1,
end: -1,
open: scanned.can_open,
close: scanned.can_close
});
}
state.pos += scanned.length;
return true;
}
// Walk through delimiter list and replace text tokens with tags
//
function postProcess(state, delimiters) {
var i, j,
startDelim,
endDelim,
token,
loneMarkers = [],
max = delimiters.length;
for (i = 0; i < max; i++) {
startDelim = delimiters[i];
if (startDelim.marker !== 0x2B/* + */) {
function postProcess(state, delimiters) {
let token;
const loneMarkers = [];
const max = delimiters.length;
for (let i = 0; i < max; i++) {
const startDelim = delimiters[i];
if (startDelim.marker !== 43 /* + */) {
continue;
}
if (startDelim.end === -1) {
continue;
}
endDelim = delimiters[startDelim.end];
token = state.tokens[startDelim.token];
token.type = 'ins_open';
token.tag = 'ins';
const endDelim = delimiters[startDelim.end];
token = state.tokens[startDelim.token];
token.type = "ins_open";
token.tag = "ins";
token.nesting = 1;
token.markup = '++';
token.content = '';
token = state.tokens[endDelim.token];
token.type = 'ins_close';
token.tag = 'ins';
token.markup = "++";
token.content = "";
token = state.tokens[endDelim.token];
token.type = "ins_close";
token.tag = "ins";
token.nesting = -1;
token.markup = '++';
token.content = '';
if (state.tokens[endDelim.token - 1].type === 'text' &&
state.tokens[endDelim.token - 1].content === '+') {
token.markup = "++";
token.content = "";
if (state.tokens[endDelim.token - 1].type === "text" && state.tokens[endDelim.token - 1].content === "+") {
loneMarkers.push(endDelim.token - 1);
}
}
// If a marker sequence has an odd number of characters, it's splitted
// like this: `~~~~~` -> `~` + `~~` + `~~`, leaving one marker at the
// start of the sequence.
//
// So, we have to move all those markers after subsequent s_close tags.
//
while (loneMarkers.length) {
i = loneMarkers.pop();
j = i + 1;
while (j < state.tokens.length && state.tokens[j].type === 'ins_close') {
while (loneMarkers.length) {
const i = loneMarkers.pop();
let j = i + 1;
while (j < state.tokens.length && state.tokens[j].type === "ins_close") {
j++;
}
j--;
if (i !== j) {

@@ -123,12 +101,8 @@ token = state.tokens[j];

}
md.inline.ruler.before('emphasis', 'ins', tokenize);
md.inline.ruler2.before('emphasis', 'ins', function (state) {
var curr,
tokens_meta = state.tokens_meta,
max = (state.tokens_meta || []).length;
md.inline.ruler.before("emphasis", "ins", tokenize);
md.inline.ruler2.before("emphasis", "ins", (function(state) {
const tokens_meta = state.tokens_meta;
const max = (state.tokens_meta || []).length;
postProcess(state, state.delimiters);
for (curr = 0; curr < max; curr++) {
for (let curr = 0; curr < max; curr++) {
if (tokens_meta[curr] && tokens_meta[curr].delimiters) {

@@ -138,7 +112,5 @@ postProcess(state, tokens_meta[curr].delimiters);

}
});
};
return markdownItIns;
})));
}));
}
return ins_plugin;
}));

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

/*! markdown-it-ins 3.0.1 https://github.com/markdown-it/markdown-it-mark @license MIT */
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).markdownitIns=n()}(this,(function(){"use strict";return function(e){function n(e,n){var t,o,s,i,r,l=[],f=n.length;for(t=0;t<f;t++)43===(s=n[t]).marker&&-1!==s.end&&(i=n[s.end],(r=e.tokens[s.token]).type="ins_open",r.tag="ins",r.nesting=1,r.markup="++",r.content="",(r=e.tokens[i.token]).type="ins_close",r.tag="ins",r.nesting=-1,r.markup="++",r.content="","text"===e.tokens[i.token-1].type&&"+"===e.tokens[i.token-1].content&&l.push(i.token-1));for(;l.length;){for(o=(t=l.pop())+1;o<e.tokens.length&&"ins_close"===e.tokens[o].type;)o++;t!==--o&&(r=e.tokens[o],e.tokens[o]=e.tokens[t],e.tokens[t]=r)}}e.inline.ruler.before("emphasis","ins",(function(e,n){var t,o,s,i,r=e.pos,l=e.src.charCodeAt(r);if(n)return!1;if(43!==l)return!1;if(s=(o=e.scanDelims(e.pos,!0)).length,i=String.fromCharCode(l),s<2)return!1;for(s%2&&(e.push("text","",0).content=i,s--),t=0;t<s;t+=2)e.push("text","",0).content=i+i,(o.can_open||o.can_close)&&e.delimiters.push({marker:l,length:0,jump:t/2,token:e.tokens.length-1,end:-1,open:o.can_open,close:o.can_close});return e.pos+=o.length,!0})),e.inline.ruler2.before("emphasis","ins",(function(e){var t,o=e.tokens_meta,s=(e.tokens_meta||[]).length;for(n(e,e.delimiters),t=0;t<s;t++)o[t]&&o[t].delimiters&&n(e,o[t].delimiters)}))}}));
/*! markdown-it-ins 4.0.0 https://github.com/markdown-it/markdown-it-ins @license MIT */
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).markdownitIns=n()}(this,(function(){"use strict";return function(e){function n(e,n){let t;const o=[],s=n.length;for(let i=0;i<s;i++){const s=n[i];if(43!==s.marker)continue;if(-1===s.end)continue;const r=n[s.end];t=e.tokens[s.token],t.type="ins_open",t.tag="ins",t.nesting=1,t.markup="++",t.content="",t=e.tokens[r.token],t.type="ins_close",t.tag="ins",t.nesting=-1,t.markup="++",t.content="","text"===e.tokens[r.token-1].type&&"+"===e.tokens[r.token-1].content&&o.push(r.token-1)}for(;o.length;){const n=o.pop();let s=n+1;for(;s<e.tokens.length&&"ins_close"===e.tokens[s].type;)s++;s--,n!==s&&(t=e.tokens[s],e.tokens[s]=e.tokens[n],e.tokens[n]=t)}}e.inline.ruler.before("emphasis","ins",(function(e,n){const t=e.pos,o=e.src.charCodeAt(t);if(n)return!1;if(43!==o)return!1;const s=e.scanDelims(e.pos,!0);let i=s.length;const r=String.fromCharCode(o);if(i<2)return!1;if(i%2){e.push("text","",0).content=r,i--}for(let n=0;n<i;n+=2){e.push("text","",0).content=r+r,(s.can_open||s.can_close)&&e.delimiters.push({marker:o,length:0,jump:n/2,token:e.tokens.length-1,end:-1,open:s.can_open,close:s.can_close})}return e.pos+=s.length,!0})),e.inline.ruler2.before("emphasis","ins",(function(e){const t=e.tokens_meta,o=(e.tokens_meta||[]).length;n(e,e.delimiters);for(let s=0;s<o;s++)t[s]&&t[s].delimiters&&n(e,t[s].delimiters)}))}}));
{
"name": "markdown-it-ins",
"version": "3.0.1",
"version": "4.0.0",
"description": "<ins> tag for markdown-it markdown parser.",

@@ -12,6 +12,19 @@ "keywords": [

],
"repository": "markdown-it/markdown-it-mark",
"repository": "markdown-it/markdown-it-ins",
"license": "MIT",
"main": "dist/index.cjs.js",
"module": "index.mjs",
"exports": {
".": {
"require": "./dist/index.cjs.js",
"import": "./index.mjs"
},
"./*": {
"require": "./*",
"import": "./*"
}
},
"files": [
"index.js",
"index.mjs",
"lib/",
"dist/"

@@ -21,18 +34,18 @@ ],

"lint": "eslint .",
"test": "npm run lint && nyc mocha",
"coverage": "npm run test && nyc report --reporter html",
"report-coveralls": "nyc --reporter=lcov mocha",
"browserify": "rollup -c"
"build": "rollup -c",
"test": "npm run lint && npm run build && c8 --exclude dist --exclude test -r text -r html -r lcov mocha",
"prepublishOnly": "npm run lint && npm run build"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^17.0.0",
"@rollup/plugin-node-resolve": "^11.0.1",
"eslint": "^7.16.0",
"markdown-it": "markdown-it/markdown-it",
"markdown-it-testgen": "~0.1.0",
"mocha": "^8.2.1",
"nyc": "^15.1.0",
"rollup": "^2.35.1",
"rollup-plugin-terser": "^7.0.2"
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-terser": "^0.4.4",
"c8": "^8.0.1",
"eslint": "^8.55.0",
"eslint-config-standard": "^17.1.0",
"markdown-it": "^13.0.2",
"markdown-it-testgen": "^0.1.6",
"mocha": "^10.2.0",
"rollup": "^4.6.1"
}
}
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