markdown-it-mark
Advanced tools
+7
-0
@@ -0,1 +1,8 @@ | ||
| 3.0.1 / 2020-12-20 | ||
| ------------------ | ||
| - Fix incorrect parsing of long (4+ length) markers. | ||
| - Upgrade build process. | ||
| 3.0.0 / 2019-09-11 | ||
@@ -2,0 +9,0 @@ ------------------ |
+108
-103
@@ -1,137 +0,142 @@ | ||
| /*! markdown-it-mark 3.0.0 https://github.com//markdown-it/markdown-it-mark @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.markdownitMark = 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-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'; | ||
| 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 markdownItMark = 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 !== 0x3D/* = */) { return false; } | ||
| if (marker !== 0x3D/* = */) { 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 !== 0x3D/* = */) { | ||
| continue; | ||
| } | ||
| if (startDelim.marker !== 0x3D/* = */) { | ||
| 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 = 'mark_open'; | ||
| token.tag = 'mark'; | ||
| token.nesting = 1; | ||
| token.markup = '=='; | ||
| token.content = ''; | ||
| 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 = ''; | ||
| 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 === '=') { | ||
| 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 === 'mark_close') { | ||
| j++; | ||
| } | ||
| while (j < state.tokens.length && state.tokens[j].type === 'mark_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', '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) { | ||
| 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 markdownItMark; | ||
| }))); |
@@ -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).markdownitMark=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 a=new Error("Cannot find module '"+s+"'");throw a.code="MODULE_NOT_FOUND",a}var p=t[s]={exports:{}};n[s][0].call(p.exports,(function(e){return r(n[s][1][e]||e)}),p,p.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++)61===(r=n[t]).marker&&-1!==r.end&&(i=n[r.end],(s=e.tokens[r.token]).type="mark_open",s.tag="mark",s.nesting=1,s.markup="==",s.content="",(s=e.tokens[i.token]).type="mark_close",s.tag="mark",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&&"mark_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","mark",(function(e,n){var t,o,r,i,s=e.pos,f=e.src.charCodeAt(s);if(n)return!1;if(61!==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","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)}))}},{}]},{},[1])(1)})); | ||
| /*! 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)}))}})); |
+2
-2
@@ -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, |
+17
-8
| { | ||
| "name": "markdown-it-mark", | ||
| "version": "3.0.0", | ||
| "version": "3.0.1", | ||
| "description": "<mark> tag for markdown-it markdown parser.", | ||
@@ -13,15 +13,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" | ||
| } | ||
| } |
+1
-1
| # markdown-it-mark | ||
| [](https://travis-ci.org/markdown-it/markdown-it-mark) | ||
| [](https://github.com/markdown-it/markdown-it-mark/actions) | ||
| [](https://www.npmjs.org/package/markdown-it-mark) | ||
@@ -5,0 +5,0 @@ [](https://coveralls.io/r/markdown-it/markdown-it-mark?branch=master) |
-27
| { | ||
| "name": "markdown-it-mark", | ||
| "main": "dist/markdown-it-mark.js", | ||
| "homepage": "https://github.com/markdown-it/markdown-it-mark", | ||
| "description": "<mark> tag for markdown-it markdown parser.", | ||
| "keywords": [ | ||
| "markdown-it-plugin", | ||
| "markdown-it", | ||
| "markdown", | ||
| "mark" | ||
| ], | ||
| "license": "MIT", | ||
| "ignore": [ | ||
| "**/.*", | ||
| "benchmark", | ||
| "bower_components", | ||
| "coverage", | ||
| "demo", | ||
| "docs", | ||
| "lib", | ||
| "node_modules", | ||
| "support", | ||
| "test", | ||
| "Makefile", | ||
| "index*" | ||
| ] | ||
| } |
12685
-5.79%9
12.5%7
-12.5%222
-10.84%