markdown-it-mark
Advanced tools
Comparing version 3.0.1 to 4.0.0
@@ -1,118 +0,95 @@ | ||
/*! markdown-it-mark 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.markdownitMark = factory()); | ||
}(this, (function () { 'use strict'; | ||
var markdownItMark = function ins_plugin(md) { | ||
/*! markdown-it-mark 4.0.0 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.markdownitMark = 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 !== 0x3D/* = */) { 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 !== 61 /* = */) { | ||
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 !== 0x3D/* = */) { | ||
function postProcess(state, delimiters) { | ||
const loneMarkers = []; | ||
const max = delimiters.length; | ||
for (let i = 0; i < max; i++) { | ||
const startDelim = delimiters[i]; | ||
if (startDelim.marker !== 61 /* = */) { | ||
continue; | ||
} | ||
if (startDelim.end === -1) { | ||
continue; | ||
} | ||
endDelim = delimiters[startDelim.end]; | ||
token = state.tokens[startDelim.token]; | ||
token.type = 'mark_open'; | ||
token.tag = 'mark'; | ||
token.nesting = 1; | ||
token.markup = '=='; | ||
token.content = ''; | ||
token = state.tokens[endDelim.token]; | ||
token.type = 'mark_close'; | ||
token.tag = 'mark'; | ||
token.nesting = -1; | ||
token.markup = '=='; | ||
token.content = ''; | ||
if (state.tokens[endDelim.token - 1].type === 'text' && | ||
state.tokens[endDelim.token - 1].content === '=') { | ||
const endDelim = delimiters[startDelim.end]; | ||
const token_o = state.tokens[startDelim.token]; | ||
token_o.type = "mark_open"; | ||
token_o.tag = "mark"; | ||
token_o.nesting = 1; | ||
token_o.markup = "=="; | ||
token_o.content = ""; | ||
const token_c = state.tokens[endDelim.token]; | ||
token_c.type = "mark_close"; | ||
token_c.tag = "mark"; | ||
token_c.nesting = -1; | ||
token_c.markup = "=="; | ||
token_c.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 === 'mark_close') { | ||
while (loneMarkers.length) { | ||
const i = loneMarkers.pop(); | ||
let j = i + 1; | ||
while (j < state.tokens.length && state.tokens[j].type === "mark_close") { | ||
j++; | ||
} | ||
j--; | ||
if (i !== j) { | ||
token = state.tokens[j]; | ||
const token = state.tokens[j]; | ||
state.tokens[j] = state.tokens[i]; | ||
@@ -123,11 +100,8 @@ state.tokens[i] = token; | ||
} | ||
md.inline.ruler.before('emphasis', 'mark', tokenize); | ||
md.inline.ruler2.before('emphasis', 'mark', function (state) { | ||
var curr, | ||
tokens_meta = state.tokens_meta, | ||
max = (state.tokens_meta || []).length; | ||
md.inline.ruler.before("emphasis", "mark", tokenize); | ||
md.inline.ruler2.before("emphasis", "mark", (function(state) { | ||
let curr; | ||
const tokens_meta = state.tokens_meta; | ||
const max = (state.tokens_meta || []).length; | ||
postProcess(state, state.delimiters); | ||
for (curr = 0; curr < max; curr++) { | ||
@@ -138,7 +112,5 @@ if (tokens_meta[curr] && tokens_meta[curr].delimiters) { | ||
} | ||
}); | ||
}; | ||
return markdownItMark; | ||
}))); | ||
})); | ||
} | ||
return ins_plugin; | ||
})); |
@@ -1,2 +0,2 @@ | ||
/*! markdown-it-mark 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).markdownitMark=n()}(this,(function(){"use strict";return function(e){function n(e,n){var t,o,r,s,i,a=[],k=n.length;for(t=0;t<k;t++)61===(r=n[t]).marker&&-1!==r.end&&(s=n[r.end],(i=e.tokens[r.token]).type="mark_open",i.tag="mark",i.nesting=1,i.markup="==",i.content="",(i=e.tokens[s.token]).type="mark_close",i.tag="mark",i.nesting=-1,i.markup="==",i.content="","text"===e.tokens[s.token-1].type&&"="===e.tokens[s.token-1].content&&a.push(s.token-1));for(;a.length;){for(o=(t=a.pop())+1;o<e.tokens.length&&"mark_close"===e.tokens[o].type;)o++;t!==--o&&(i=e.tokens[o],e.tokens[o]=e.tokens[t],e.tokens[t]=i)}}e.inline.ruler.before("emphasis","mark",(function(e,n){var t,o,r,s,i=e.pos,a=e.src.charCodeAt(i);if(n)return!1;if(61!==a)return!1;if(r=(o=e.scanDelims(e.pos,!0)).length,s=String.fromCharCode(a),r<2)return!1;for(r%2&&(e.push("text","",0).content=s,r--),t=0;t<r;t+=2)e.push("text","",0).content=s+s,(o.can_open||o.can_close)&&e.delimiters.push({marker:a,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","mark",(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)}))}})); | ||
/*! markdown-it-mark 4.0.0 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).markdownitMark=n()}(this,(function(){"use strict";return function(e){function n(e,n){const t=[],o=n.length;for(let s=0;s<o;s++){const o=n[s];if(61!==o.marker)continue;if(-1===o.end)continue;const r=n[o.end],i=e.tokens[o.token];i.type="mark_open",i.tag="mark",i.nesting=1,i.markup="==",i.content="";const c=e.tokens[r.token];c.type="mark_close",c.tag="mark",c.nesting=-1,c.markup="==",c.content="","text"===e.tokens[r.token-1].type&&"="===e.tokens[r.token-1].content&&t.push(r.token-1)}for(;t.length;){const n=t.pop();let o=n+1;for(;o<e.tokens.length&&"mark_close"===e.tokens[o].type;)o++;if(o--,n!==o){const t=e.tokens[o];e.tokens[o]=e.tokens[n],e.tokens[n]=t}}}e.inline.ruler.before("emphasis","mark",(function(e,n){const t=e.pos,o=e.src.charCodeAt(t);if(n)return!1;if(61!==o)return!1;const s=e.scanDelims(e.pos,!0);let r=s.length;const i=String.fromCharCode(o);if(r<2)return!1;if(r%2){e.push("text","",0).content=i,r--}for(let n=0;n<r;n+=2){e.push("text","",0).content=i+i,(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","mark",(function(e){let t;const 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)}))}})); |
{ | ||
"name": "markdown-it-mark", | ||
"version": "3.0.1", | ||
"version": "4.0.0", | ||
"description": "<mark> tag for markdown-it markdown parser.", | ||
@@ -13,4 +13,17 @@ "keywords": [ | ||
"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/" | ||
@@ -20,18 +33,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" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15683
325
10
1