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.0 to 3.0.1

10

CHANGELOG.md

@@ -0,7 +1,15 @@

3.0.1 / 2020-12-20
------------------
- Fix incorrect parsing of long (4+ length) markers.
- Upgrade build process.
3.0.0 / 2019-09-11
------------------
- Markdown-it 5.0.0 support + related fixes in pairs parse.
- Markdown-it 10.0.0 support + related fixes in pairs parse.
- uglify-js => terser.
2.0.0 / 2015-10-05

@@ -8,0 +16,0 @@ ------------------

211

dist/markdown-it-ins.js

@@ -1,137 +0,142 @@

/*! markdown-it-ins 3.0.0 https://github.com//markdown-it/markdown-it-ins @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.markdownitIns = 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';
/*! 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';
module.exports = 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);
var markdownItIns = 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 (silent) { return false; }
if (marker !== 0x2B/* + */) { return false; }
if (marker !== 0x2B/* + */) { return false; }
scanned = state.scanDelims(state.pos, true);
len = scanned.length;
ch = String.fromCharCode(marker);
scanned = state.scanDelims(state.pos, true);
len = scanned.length;
ch = String.fromCharCode(marker);
if (len < 2) { return false; }
if (len < 2) { return false; }
if (len % 2) {
token = state.push('text', '', 0);
token.content = ch;
len--;
}
if (len % 2) {
token = state.push('text', '', 0);
token.content = ch;
len--;
}
for (i = 0; i < len; i += 2) {
token = state.push('text', '', 0);
token.content = ch + ch;
for (i = 0; i < len; i += 2) {
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,
token: state.tokens.length - 1,
end: -1,
open: scanned.can_open,
close: scanned.can_close
});
}
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
});
}
state.pos += scanned.length;
state.pos += scanned.length;
return true;
}
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;
// 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];
for (i = 0; i < max; i++) {
startDelim = delimiters[i];
if (startDelim.marker !== 0x2B/* + */) {
continue;
}
if (startDelim.marker !== 0x2B/* + */) {
continue;
}
if (startDelim.end === -1) {
continue;
}
if (startDelim.end === -1) {
continue;
}
endDelim = delimiters[startDelim.end];
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[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.nesting = -1;
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 === '+') {
if (state.tokens[endDelim.token - 1].type === 'text' &&
state.tokens[endDelim.token - 1].content === '+') {
loneMarkers.push(endDelim.token - 1);
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;
// 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') {
j++;
}
while (j < state.tokens.length && state.tokens[j].type === 'ins_close') {
j++;
}
j--;
j--;
if (i !== j) {
token = state.tokens[j];
state.tokens[j] = state.tokens[i];
state.tokens[i] = token;
if (i !== j) {
token = state.tokens[j];
state.tokens[j] = state.tokens[i];
state.tokens[i] = token;
}
}
}
}
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) {
var curr,
tokens_meta = state.tokens_meta,
max = (state.tokens_meta || []).length;
postProcess(state, state.delimiters);
postProcess(state, state.delimiters);
for (curr = 0; curr < max; curr++) {
if (tokens_meta[curr] && tokens_meta[curr].delimiters) {
postProcess(state, tokens_meta[curr].delimiters);
for (curr = 0; curr < max; curr++) {
if (tokens_meta[curr] && tokens_meta[curr].delimiters) {
postProcess(state, tokens_meta[curr].delimiters);
}
}
}
});
};
});
};
},{}]},{},[1])(1)
});
return markdownItIns;
})));

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

!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).markdownitIns=e()}}((function(){return function e(n,t,o){function r(s,f){if(!t[s]){if(!n[s]){var u="function"==typeof require&&require;if(!f&&u)return u(s,!0);if(i)return i(s,!0);var p=new Error("Cannot find module '"+s+"'");throw p.code="MODULE_NOT_FOUND",p}var l=t[s]={exports:{}};n[s][0].call(l.exports,(function(e){return r(n[s][1][e]||e)}),l,l.exports,e,n,t,o)}return t[s].exports}for(var i="function"==typeof require&&require,s=0;s<o.length;s++)r(o[s]);return r}({1:[function(e,n,t){"use strict";n.exports=function(e){function n(e,n){var t,o,r,i,s,f=[],u=n.length;for(t=0;t<u;t++)43===(r=n[t]).marker&&-1!==r.end&&(i=n[r.end],(s=e.tokens[r.token]).type="ins_open",s.tag="ins",s.nesting=1,s.markup="++",s.content="",(s=e.tokens[i.token]).type="ins_close",s.tag="ins",s.nesting=-1,s.markup="++",s.content="","text"===e.tokens[i.token-1].type&&"+"===e.tokens[i.token-1].content&&f.push(i.token-1));for(;f.length;){for(o=(t=f.pop())+1;o<e.tokens.length&&"ins_close"===e.tokens[o].type;)o++;t!==--o&&(s=e.tokens[o],e.tokens[o]=e.tokens[t],e.tokens[t]=s)}}e.inline.ruler.before("emphasis","ins",(function(e,n){var t,o,r,i,s=e.pos,f=e.src.charCodeAt(s);if(n)return!1;if(43!==f)return!1;if(r=(o=e.scanDelims(e.pos,!0)).length,i=String.fromCharCode(f),r<2)return!1;for(r%2&&(e.push("text","",0).content=i,r--),t=0;t<r;t+=2)e.push("text","",0).content=i+i,(o.can_open||o.can_close)&&e.delimiters.push({marker:f,length:0,jump:t,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,r=(e.tokens_meta||[]).length;for(n(e,e.delimiters),t=0;t<r;t++)o[t]&&o[t].delimiters&&n(e,o[t].delimiters)}))}},{}]},{},[1])(1)}));
/*! 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)}))}}));

@@ -36,4 +36,4 @@ 'use strict';

marker: marker,
length: 0, // disable "rule of 3" length checks meant for emphasis
jump: i,
length: 0, // disable "rule of 3" length checks meant for emphasis
jump: i / 2, // 1 delimiter = 2 characters
token: state.tokens.length - 1,

@@ -40,0 +40,0 @@ end: -1,

{
"name": "markdown-it-ins",
"version": "3.0.0",
"version": "3.0.1",
"description": "<ins> tag for markdown-it markdown parser.",

@@ -14,15 +14,24 @@ "keywords": [

"license": "MIT",
"files": [
"index.js",
"dist/"
],
"scripts": {
"test": "make test"
"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"
},
"devDependencies": {
"browserify": "*",
"coveralls": "^2.11.2",
"eslint": "^3.5.0",
"istanbul": "*",
"@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": "*",
"terser": "^4.3.1"
"mocha": "^8.2.1",
"nyc": "^15.1.0",
"rollup": "^2.35.1",
"rollup-plugin-terser": "^7.0.2"
}
}
# markdown-it-ins
[![Build Status](https://img.shields.io/travis/markdown-it/markdown-it-ins/master.svg?style=flat)](https://travis-ci.org/markdown-it/markdown-it-ins)
[![CI](https://github.com/markdown-it/markdown-it-ins/workflows/CI/badge.svg?branch=master)](https://github.com/markdown-it/markdown-it-ins/actions)
[![NPM version](https://img.shields.io/npm/v/markdown-it-ins.svg?style=flat)](https://www.npmjs.org/package/markdown-it-ins)

@@ -5,0 +5,0 @@ [![Coverage Status](https://img.shields.io/coveralls/markdown-it/markdown-it-ins/master.svg?style=flat)](https://coveralls.io/r/markdown-it/markdown-it-ins?branch=master)

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