markdown-it-ins
Advanced tools
Comparing version 0.1.0 to 1.0.0
@@ -0,1 +1,7 @@ | ||
1.0.0 / 2015-03-12 | ||
------------------ | ||
- Markdown-it 4.0.0 support. Use previous version for 2.x-3.x. | ||
0.1.0 / 2015-01-04 | ||
@@ -2,0 +8,0 @@ ------------------ |
@@ -1,2 +0,2 @@ | ||
/*! markdown-it-ins 0.1.0 https://github.com//markdown-it/markdown-it-ins @license MIT */!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n;"undefined"!=typeof window?n=window:"undefined"!=typeof global?n=global:"undefined"!=typeof self&&(n=self),n.markdownitIns=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
/*! markdown-it-ins 1.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 e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
'use strict'; | ||
@@ -9,19 +9,48 @@ | ||
var pos = start, lastChar, nextChar, count, | ||
isLastWhiteSpace, isLastPunctChar, | ||
isNextWhiteSpace, isNextPunctChar, | ||
can_open = true, | ||
can_close = true, | ||
max = state.posMax, | ||
marker = state.src.charCodeAt(start); | ||
marker = state.src.charCodeAt(start), | ||
isWhiteSpace = state.md.utils.isWhiteSpace, | ||
isPunctChar = state.md.utils.isPunctChar, | ||
isMdAsciiPunct = state.md.utils.isMdAsciiPunct; | ||
lastChar = start > 0 ? state.src.charCodeAt(start - 1) : -1; | ||
// treat beginning of the line as a whitespace | ||
lastChar = start > 0 ? state.src.charCodeAt(start - 1) : 0x20; | ||
while (pos < max && state.src.charCodeAt(pos) === marker) { pos++; } | ||
if (pos >= max) { can_open = false; } | ||
if (pos >= max) { | ||
can_open = false; | ||
} | ||
count = pos - start; | ||
nextChar = pos < max ? state.src.charCodeAt(pos) : -1; | ||
// treat end of the line as a whitespace | ||
nextChar = pos < max ? state.src.charCodeAt(pos) : 0x20; | ||
// check whitespace conditions | ||
if (nextChar === 0x20 || nextChar === 0x0A) { can_open = false; } | ||
if (lastChar === 0x20 || lastChar === 0x0A) { can_close = false; } | ||
isLastPunctChar = isMdAsciiPunct(lastChar) || isPunctChar(String.fromCharCode(lastChar)); | ||
isNextPunctChar = isMdAsciiPunct(nextChar) || isPunctChar(String.fromCharCode(nextChar)); | ||
isLastWhiteSpace = isWhiteSpace(lastChar); | ||
isNextWhiteSpace = isWhiteSpace(nextChar); | ||
if (isNextWhiteSpace) { | ||
can_open = false; | ||
} else if (isNextPunctChar) { | ||
if (!(isLastWhiteSpace || isLastPunctChar)) { | ||
can_open = false; | ||
} | ||
} | ||
if (isLastWhiteSpace) { | ||
can_close = false; | ||
} else if (isLastPunctChar) { | ||
if (!(isNextWhiteSpace || isNextPunctChar)) { | ||
can_close = false; | ||
} | ||
} | ||
return { | ||
@@ -42,2 +71,3 @@ can_open: can_open, | ||
res, | ||
token, | ||
max = state.posMax, | ||
@@ -99,6 +129,10 @@ start = state.pos, | ||
// Earlier we checked !silent, but this implementation does not need it | ||
state.push({ type: 'ins_open', level: state.level++ }); | ||
token = state.push('ins_open', 'ins', 1); | ||
token.markup = String.fromCharCode(marker) + String.fromCharCode(marker); | ||
state.md.inline.tokenize(state); | ||
state.push({ type: 'ins_close', level: --state.level }); | ||
token = state.push('ins_close', 'ins', -1); | ||
token.markup = String.fromCharCode(marker) + String.fromCharCode(marker); | ||
state.pos = state.posMax + 2; | ||
@@ -110,10 +144,4 @@ state.posMax = max; | ||
function ins_open() { return '<ins>'; } | ||
function ins_close() { return '</ins>'; } | ||
module.exports = function ins_plugin(md) { | ||
md.inline.ruler.before('emphasis', 'ins', insert); | ||
md.renderer.rules.ins_open = ins_open; | ||
md.renderer.rules.ins_close = ins_close; | ||
}; | ||
@@ -120,0 +148,0 @@ |
@@ -1,2 +0,2 @@ | ||
/*! markdown-it-ins 0.1.0 https://github.com//markdown-it/markdown-it-ins @license MIT */ | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n;"undefined"!=typeof window?n=window:"undefined"!=typeof global?n=global:"undefined"!=typeof self&&(n=self),n.markdownitIns=e()}}(function(){return function e(n,o,r){function i(t,f){if(!o[t]){if(!n[t]){var p="function"==typeof require&&require;if(!f&&p)return p(t,!0);if(s)return s(t,!0);var u=new Error("Cannot find module '"+t+"'");throw u.code="MODULE_NOT_FOUND",u}var c=o[t]={exports:{}};n[t][0].call(c.exports,function(e){var o=n[t][1][e];return i(o?o:e)},c,c.exports,e,n,o,r)}return o[t].exports}for(var s="function"==typeof require&&require,t=0;t<r.length;t++)i(r[t]);return i}({1:[function(e,n){"use strict";function o(e,n){var o,r,i,s=n,t=!0,f=!0,p=e.posMax,u=e.src.charCodeAt(n);for(o=n>0?e.src.charCodeAt(n-1):-1;p>s&&e.src.charCodeAt(s)===u;)s++;return s>=p&&(t=!1),i=s-n,r=p>s?e.src.charCodeAt(s):-1,(32===r||10===r)&&(t=!1),(32===o||10===o)&&(f=!1),{can_open:t,can_close:f,delims:i}}function r(e,n){var r,i,s,t,f,p,u=e.posMax,c=e.pos,l=e.src.charCodeAt(c);if(43!==l)return!1;if(n)return!1;if(p=o(e,c),r=p.delims,!p.can_open)return e.pos+=r,e.pending+=e.src.slice(c,e.pos),!0;if(f=Math.floor(r/2),0>=f)return!1;for(e.pos=c+r;e.pos<u;)if(e.src.charCodeAt(e.pos)!==l)e.md.inline.skipToken(e);else{if(p=o(e,e.pos),i=p.delims,s=Math.floor(i/2),p.can_close){if(s>=f){e.pos+=i-2,t=!0;break}f-=s,e.pos+=i;continue}p.can_open&&(f+=s),e.pos+=i}return t?(e.posMax=e.pos,e.pos=c+2,e.push({type:"ins_open",level:e.level++}),e.md.inline.tokenize(e),e.push({type:"ins_close",level:--e.level}),e.pos=e.posMax+2,e.posMax=u,!0):(e.pos=c,!1)}function i(){return"<ins>"}function s(){return"</ins>"}n.exports=function(e){e.inline.ruler.before("emphasis","ins",r),e.renderer.rules.ins_open=i,e.renderer.rules.ins_close=s}},{}]},{},[1])(1)}); | ||
/*! markdown-it-ins 1.0.0 https://github.com//markdown-it/markdown-it-ins @license MIT */ | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var r;r="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,r.markdownitIns=e()}}(function(){return function e(r,o,n){function i(s,f){if(!o[s]){if(!r[s]){var u="function"==typeof require&&require;if(!f&&u)return u(s,!0);if(t)return t(s,!0);var p=new Error("Cannot find module '"+s+"'");throw p.code="MODULE_NOT_FOUND",p}var a=o[s]={exports:{}};r[s][0].call(a.exports,function(e){var o=r[s][1][e];return i(o?o:e)},a,a.exports,e,r,o,n)}return o[s].exports}for(var t="function"==typeof require&&require,s=0;s<n.length;s++)i(n[s]);return i}({1:[function(e,r){"use strict";function o(e,r){var o,n,i,t,s,f,u,p=r,a=!0,c=!0,d=e.posMax,l=e.src.charCodeAt(r),h=e.md.utils.isWhiteSpace,m=e.md.utils.isPunctChar,C=e.md.utils.isMdAsciiPunct;for(o=r>0?e.src.charCodeAt(r-1):32;d>p&&e.src.charCodeAt(p)===l;)p++;return p>=d&&(a=!1),i=p-r,n=d>p?e.src.charCodeAt(p):32,s=C(o)||m(String.fromCharCode(o)),u=C(n)||m(String.fromCharCode(n)),t=h(o),f=h(n),f?a=!1:u&&(t||s||(a=!1)),t?c=!1:s&&(f||u||(c=!1)),{can_open:a,can_close:c,delims:i}}function n(e,r){var n,i,t,s,f,u,p,a=e.posMax,c=e.pos,d=e.src.charCodeAt(c);if(43!==d)return!1;if(r)return!1;if(u=o(e,c),n=u.delims,!u.can_open)return e.pos+=n,e.pending+=e.src.slice(c,e.pos),!0;if(f=Math.floor(n/2),0>=f)return!1;for(e.pos=c+n;e.pos<a;)if(e.src.charCodeAt(e.pos)!==d)e.md.inline.skipToken(e);else{if(u=o(e,e.pos),i=u.delims,t=Math.floor(i/2),u.can_close){if(t>=f){e.pos+=i-2,s=!0;break}f-=t,e.pos+=i;continue}u.can_open&&(f+=t),e.pos+=i}return s?(e.posMax=e.pos,e.pos=c+2,p=e.push("ins_open","ins",1),p.markup=String.fromCharCode(d)+String.fromCharCode(d),e.md.inline.tokenize(e),p=e.push("ins_close","ins",-1),p.markup=String.fromCharCode(d)+String.fromCharCode(d),e.pos=e.posMax+2,e.posMax=a,!0):(e.pos=c,!1)}r.exports=function(e){e.inline.ruler.before("emphasis","ins",n)}},{}]},{},[1])(1)}); |
58
index.js
@@ -8,19 +8,48 @@ 'use strict'; | ||
var pos = start, lastChar, nextChar, count, | ||
isLastWhiteSpace, isLastPunctChar, | ||
isNextWhiteSpace, isNextPunctChar, | ||
can_open = true, | ||
can_close = true, | ||
max = state.posMax, | ||
marker = state.src.charCodeAt(start); | ||
marker = state.src.charCodeAt(start), | ||
isWhiteSpace = state.md.utils.isWhiteSpace, | ||
isPunctChar = state.md.utils.isPunctChar, | ||
isMdAsciiPunct = state.md.utils.isMdAsciiPunct; | ||
lastChar = start > 0 ? state.src.charCodeAt(start - 1) : -1; | ||
// treat beginning of the line as a whitespace | ||
lastChar = start > 0 ? state.src.charCodeAt(start - 1) : 0x20; | ||
while (pos < max && state.src.charCodeAt(pos) === marker) { pos++; } | ||
if (pos >= max) { can_open = false; } | ||
if (pos >= max) { | ||
can_open = false; | ||
} | ||
count = pos - start; | ||
nextChar = pos < max ? state.src.charCodeAt(pos) : -1; | ||
// treat end of the line as a whitespace | ||
nextChar = pos < max ? state.src.charCodeAt(pos) : 0x20; | ||
// check whitespace conditions | ||
if (nextChar === 0x20 || nextChar === 0x0A) { can_open = false; } | ||
if (lastChar === 0x20 || lastChar === 0x0A) { can_close = false; } | ||
isLastPunctChar = isMdAsciiPunct(lastChar) || isPunctChar(String.fromCharCode(lastChar)); | ||
isNextPunctChar = isMdAsciiPunct(nextChar) || isPunctChar(String.fromCharCode(nextChar)); | ||
isLastWhiteSpace = isWhiteSpace(lastChar); | ||
isNextWhiteSpace = isWhiteSpace(nextChar); | ||
if (isNextWhiteSpace) { | ||
can_open = false; | ||
} else if (isNextPunctChar) { | ||
if (!(isLastWhiteSpace || isLastPunctChar)) { | ||
can_open = false; | ||
} | ||
} | ||
if (isLastWhiteSpace) { | ||
can_close = false; | ||
} else if (isLastPunctChar) { | ||
if (!(isNextWhiteSpace || isNextPunctChar)) { | ||
can_close = false; | ||
} | ||
} | ||
return { | ||
@@ -41,2 +70,3 @@ can_open: can_open, | ||
res, | ||
token, | ||
max = state.posMax, | ||
@@ -98,6 +128,10 @@ start = state.pos, | ||
// Earlier we checked !silent, but this implementation does not need it | ||
state.push({ type: 'ins_open', level: state.level++ }); | ||
token = state.push('ins_open', 'ins', 1); | ||
token.markup = String.fromCharCode(marker) + String.fromCharCode(marker); | ||
state.md.inline.tokenize(state); | ||
state.push({ type: 'ins_close', level: --state.level }); | ||
token = state.push('ins_close', 'ins', -1); | ||
token.markup = String.fromCharCode(marker) + String.fromCharCode(marker); | ||
state.pos = state.posMax + 2; | ||
@@ -109,10 +143,4 @@ state.posMax = max; | ||
function ins_open() { return '<ins>'; } | ||
function ins_close() { return '</ins>'; } | ||
module.exports = function ins_plugin(md) { | ||
md.inline.ruler.before('emphasis', 'ins', insert); | ||
md.renderer.rules.ins_open = ins_open; | ||
md.renderer.rules.ins_close = ins_close; | ||
}; |
{ | ||
"name": "markdown-it-ins", | ||
"version": "0.1.0", | ||
"version": "1.0.0", | ||
"description": "<ins> tag for markdown-it markdown parser.", | ||
@@ -32,3 +32,3 @@ "keywords": [ | ||
"lodash": "*", | ||
"markdown-it": "~3.0.0", | ||
"markdown-it": "4.0.0", | ||
"markdown-it-testgen": "~0.1.0", | ||
@@ -35,0 +35,0 @@ "mocha": "*", |
@@ -9,2 +9,4 @@ # markdown-it-ins | ||
__v1.+ requires `markdown-it` v4.+, see changelog.__ | ||
`++inserted++` => `<ins>inserted</ins>` | ||
@@ -11,0 +13,0 @@ |
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
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
14209
260
1
41