markdown-it
Advanced tools
Comparing version 12.3.2 to 13.0.0
@@ -19,3 +19,6 @@ /** internal | ||
[ 'replacements', require('./rules_core/replacements') ], | ||
[ 'smartquotes', require('./rules_core/smartquotes') ] | ||
[ 'smartquotes', require('./rules_core/smartquotes') ], | ||
// `text_join` finds `text_special` tokens (for escape sequences) | ||
// and joins them with the rest of the text | ||
[ 'text_join', require('./rules_core/text_join') ] | ||
]; | ||
@@ -22,0 +25,0 @@ |
@@ -17,2 +17,3 @@ /** internal | ||
[ 'text', require('./rules_inline/text') ], | ||
[ 'linkify', require('./rules_inline/linkify') ], | ||
[ 'newline', require('./rules_inline/newline') ], | ||
@@ -30,2 +31,7 @@ [ 'escape', require('./rules_inline/escape') ], | ||
// `rule2` ruleset was created specifically for emphasis/strikethrough | ||
// post-processing and may be changed in the future. | ||
// | ||
// Don't use this for anything except pairs (plugins working with `balance_pairs`). | ||
// | ||
var _rules2 = [ | ||
@@ -35,3 +41,5 @@ [ 'balance_pairs', require('./rules_inline/balance_pairs') ], | ||
[ 'emphasis', require('./rules_inline/emphasis').postProcess ], | ||
[ 'text_collapse', require('./rules_inline/text_collapse') ] | ||
// rules for pairs separate '**' into its own text tokens, which may be left unused, | ||
// rule below merges unused segments back with the rest of the text | ||
[ 'fragments_join', require('./rules_inline/fragments_join') ] | ||
]; | ||
@@ -38,0 +46,0 @@ |
@@ -41,3 +41,4 @@ // Commonmark default options | ||
'block', | ||
'inline' | ||
'inline', | ||
'text_join' | ||
] | ||
@@ -77,3 +78,3 @@ }, | ||
'emphasis', | ||
'text_collapse' | ||
'fragments_join' | ||
] | ||
@@ -80,0 +81,0 @@ } |
@@ -42,3 +42,4 @@ // "Zero" preset, with nothing enabled. Useful for manual configuring of simple | ||
'block', | ||
'inline' | ||
'inline', | ||
'text_join' | ||
] | ||
@@ -59,3 +60,3 @@ }, | ||
'balance_pairs', | ||
'text_collapse' | ||
'fragments_join' | ||
] | ||
@@ -62,0 +63,0 @@ } |
@@ -12,3 +12,3 @@ // GFM table, https://github.github.com/gfm/#tables-extension- | ||
return state.src.substr(pos, max - pos); | ||
return state.src.slice(pos, max); | ||
} | ||
@@ -15,0 +15,0 @@ |
@@ -72,4 +72,13 @@ // Replace link-like texts with link nodes. | ||
// forbid escape sequence at the start of the string, | ||
// this avoids http\://example.com/ from being linkified as | ||
// http:<a href="//example.com/">//example.com/</a> | ||
if (links.length > 0 && | ||
links[0].index === 0 && | ||
i > 0 && | ||
tokens[i - 1].type === 'text_special') { | ||
links = links.slice(1); | ||
} | ||
for (ln = 0; ln < links.length; ln++) { | ||
url = links[ln].url; | ||
@@ -76,0 +85,0 @@ fullUrl = state.md.normalizeLink(url); |
@@ -16,3 +16,3 @@ // Simple typographic replacements | ||
// - fractionals 1/2, 1/4, 3/4 -> ½, ¼, ¾ | ||
// - miltiplication 2 x 4 -> 2 × 4 | ||
// - multiplications 2 x 4 -> 2 × 4 | ||
@@ -23,9 +23,8 @@ var RARE_RE = /\+-|\.\.|\?\?\?\?|!!!!|,,|--/; | ||
// or root check will fail every second time | ||
var SCOPED_ABBR_TEST_RE = /\((c|tm|r|p)\)/i; | ||
var SCOPED_ABBR_TEST_RE = /\((c|tm|r)\)/i; | ||
var SCOPED_ABBR_RE = /\((c|tm|r|p)\)/ig; | ||
var SCOPED_ABBR_RE = /\((c|tm|r)\)/ig; | ||
var SCOPED_ABBR = { | ||
c: '©', | ||
r: '®', | ||
p: '§', | ||
tm: '™' | ||
@@ -32,0 +31,0 @@ }; |
@@ -16,3 +16,3 @@ // Convert straight quotation marks to typographic ones | ||
function replaceAt(str, index, ch) { | ||
return str.substr(0, index) + ch + str.substr(index + 1); | ||
return str.slice(0, index) + ch + str.slice(index + 1); | ||
} | ||
@@ -19,0 +19,0 @@ |
@@ -16,15 +16,33 @@ // Process html entity - {, ¯, ", ... | ||
module.exports = function entity(state, silent) { | ||
var ch, code, match, pos = state.pos, max = state.posMax; | ||
var ch, code, match, token, pos = state.pos, max = state.posMax; | ||
if (state.src.charCodeAt(pos) !== 0x26/* & */) { return false; } | ||
if (state.src.charCodeAt(pos) !== 0x26/* & */) return false; | ||
if (pos + 1 < max) { | ||
ch = state.src.charCodeAt(pos + 1); | ||
if (pos + 1 >= max) return false; | ||
if (ch === 0x23 /* # */) { | ||
match = state.src.slice(pos).match(DIGITAL_RE); | ||
if (match) { | ||
ch = state.src.charCodeAt(pos + 1); | ||
if (ch === 0x23 /* # */) { | ||
match = state.src.slice(pos).match(DIGITAL_RE); | ||
if (match) { | ||
if (!silent) { | ||
code = match[1][0].toLowerCase() === 'x' ? parseInt(match[1].slice(1), 16) : parseInt(match[1], 10); | ||
token = state.push('text_special', '', 0); | ||
token.content = isValidEntityCode(code) ? fromCodePoint(code) : fromCodePoint(0xFFFD); | ||
token.markup = match[0]; | ||
token.info = 'entity'; | ||
} | ||
state.pos += match[0].length; | ||
return true; | ||
} | ||
} else { | ||
match = state.src.slice(pos).match(NAMED_RE); | ||
if (match) { | ||
if (has(entities, match[1])) { | ||
if (!silent) { | ||
code = match[1][0].toLowerCase() === 'x' ? parseInt(match[1].slice(1), 16) : parseInt(match[1], 10); | ||
state.pending += isValidEntityCode(code) ? fromCodePoint(code) : fromCodePoint(0xFFFD); | ||
token = state.push('text_special', '', 0); | ||
token.content = entities[match[1]]; | ||
token.markup = match[0]; | ||
token.info = 'entity'; | ||
} | ||
@@ -34,17 +52,6 @@ state.pos += match[0].length; | ||
} | ||
} else { | ||
match = state.src.slice(pos).match(NAMED_RE); | ||
if (match) { | ||
if (has(entities, match[1])) { | ||
if (!silent) { state.pending += entities[match[1]]; } | ||
state.pos += match[0].length; | ||
return true; | ||
} | ||
} | ||
} | ||
} | ||
if (!silent) { state.pending += '&'; } | ||
state.pos++; | ||
return true; | ||
return false; | ||
}; |
@@ -16,38 +16,57 @@ // Process escaped chars and hardbreaks | ||
module.exports = function escape(state, silent) { | ||
var ch, pos = state.pos, max = state.posMax; | ||
var ch1, ch2, origStr, escapedStr, token, pos = state.pos, max = state.posMax; | ||
if (state.src.charCodeAt(pos) !== 0x5C/* \ */) { return false; } | ||
if (state.src.charCodeAt(pos) !== 0x5C/* \ */) return false; | ||
pos++; | ||
if (pos < max) { | ||
ch = state.src.charCodeAt(pos); | ||
// '\' at the end of the inline block | ||
if (pos >= max) return false; | ||
if (ch < 256 && ESCAPED[ch] !== 0) { | ||
if (!silent) { state.pending += state.src[pos]; } | ||
state.pos += 2; | ||
return true; | ||
ch1 = state.src.charCodeAt(pos); | ||
if (ch1 === 0x0A) { | ||
if (!silent) { | ||
state.push('hardbreak', 'br', 0); | ||
} | ||
if (ch === 0x0A) { | ||
if (!silent) { | ||
state.push('hardbreak', 'br', 0); | ||
} | ||
pos++; | ||
// skip leading whitespaces from next line | ||
while (pos < max) { | ||
ch1 = state.src.charCodeAt(pos); | ||
if (!isSpace(ch1)) break; | ||
pos++; | ||
} | ||
state.pos = pos; | ||
return true; | ||
} | ||
escapedStr = state.src[pos]; | ||
if (ch1 >= 0xD800 && ch1 <= 0xDBFF && pos + 1 < max) { | ||
ch2 = state.src.charCodeAt(pos + 1); | ||
if (ch2 >= 0xDC00 && ch2 <= 0xDFFF) { | ||
escapedStr += state.src[pos + 1]; | ||
pos++; | ||
// skip leading whitespaces from next line | ||
while (pos < max) { | ||
ch = state.src.charCodeAt(pos); | ||
if (!isSpace(ch)) { break; } | ||
pos++; | ||
} | ||
} | ||
} | ||
state.pos = pos; | ||
return true; | ||
origStr = '\\' + escapedStr; | ||
if (!silent) { | ||
token = state.push('text_special', '', 0); | ||
if (ch1 < 256 && ESCAPED[ch1] !== 0) { | ||
token.content = escapedStr; | ||
} else { | ||
token.content = origStr; | ||
} | ||
token.markup = origStr; | ||
token.info = 'escape'; | ||
} | ||
if (!silent) { state.pending += '\\'; } | ||
state.pos++; | ||
state.pos = pos + 1; | ||
return true; | ||
}; |
@@ -9,2 +9,10 @@ // Process html tags | ||
function isLinkOpen(str) { | ||
return /^<a[>\s]/i.test(str); | ||
} | ||
function isLinkClose(str) { | ||
return /^<\/a\s*>/i.test(str); | ||
} | ||
function isLetter(ch) { | ||
@@ -45,2 +53,5 @@ /*eslint no-bitwise:0*/ | ||
token.content = state.src.slice(pos, pos + match[0].length); | ||
if (isLinkOpen(token.content)) state.linkLevel++; | ||
if (isLinkClose(token.content)) state.linkLevel--; | ||
} | ||
@@ -47,0 +58,0 @@ state.pos += match[0].length; |
@@ -140,3 +140,5 @@ // Process [link](<to> "stuff") | ||
state.linkLevel++; | ||
state.md.inline.tokenize(state); | ||
state.linkLevel--; | ||
@@ -143,0 +145,0 @@ token = state.push('link_close', 'a', -1); |
@@ -38,2 +38,6 @@ // Inline parser state | ||
this.backticksScanned = false; | ||
// Counter used to disable inline linkify-it execution | ||
// inside <a> and markdown links | ||
this.linkLevel = 0; | ||
} | ||
@@ -40,0 +44,0 @@ |
{ | ||
"name": "markdown-it", | ||
"version": "12.3.2", | ||
"version": "13.0.0", | ||
"description": "Markdown-it - modern pluggable markdown parser.", | ||
@@ -41,4 +41,4 @@ "keywords": [ | ||
"argparse": "^2.0.1", | ||
"entities": "~2.1.0", | ||
"linkify-it": "^3.0.1", | ||
"entities": "~3.0.1", | ||
"linkify-it": "^4.0.0", | ||
"mdurl": "^1.0.1", | ||
@@ -45,0 +45,0 @@ "uc.micro": "^1.0.5" |
@@ -230,3 +230,3 @@ # markdown-it <!-- omit in toc --> | ||
```js | ||
// Activate/deactivate rules, with curring | ||
// Activate/deactivate rules, with currying | ||
var md = require('markdown-it')() | ||
@@ -233,0 +233,0 @@ .disable([ 'link', 'image' ]) |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
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
565390
60
13992
+ Addedentities@3.0.1(transitive)
+ Addedlinkify-it@4.0.1(transitive)
- Removedentities@2.1.0(transitive)
- Removedlinkify-it@3.0.3(transitive)
Updatedentities@~3.0.1
Updatedlinkify-it@^4.0.0