markdown-it
Advanced tools
Comparing version 3.0.0 to 3.0.1
@@ -0,1 +1,8 @@ | ||
3.0.1 / 2015-01-07 | ||
------------------ | ||
- Improved link encoder - fix invalid surrogates to avoid errors. | ||
- Added # to terminator chars. | ||
3.0.0 / 2015-01-04 | ||
@@ -10,3 +17,3 @@ ------------------ | ||
- References/Footnotes/Abbrs moved to `block` chain. | ||
- Input normalisation moved to `core` chain. | ||
- Input normalization moved to `core` chain. | ||
- Splitted links and images to separate rules. | ||
@@ -13,0 +20,0 @@ - Renamed some rules. |
@@ -133,4 +133,42 @@ // Utilities | ||
var SURRORATE_TEST_RE = /[\uD800-\uDFFF]/; | ||
var SURRORATE_SEARCH_RE = /[\uD800-\uDFFF]/g; | ||
function replaceBadSurrogate(ch, pos, orig) { | ||
var code = ch.charCodeAt(0); | ||
if (code >= 0xD800 && code <= 0xDBFF) { | ||
// high surrogate | ||
if (pos >= orig.length - 1) { return '\uFFFD'; } | ||
code = orig.charCodeAt(pos + 1); | ||
if (code < 0xDC00 || code > 0xDFFF) { return '\uFFFD'; } | ||
return ch; | ||
} | ||
// low surrogate | ||
if (pos === 0) { return '\uFFFD'; } | ||
code = orig.charCodeAt(pos - 1); | ||
if (code < 0xD900 || code > 0xDBFF) { return '\uFFFD'; } | ||
return ch; | ||
} | ||
function fixBrokenSurrogates(str) { | ||
if (!SURRORATE_TEST_RE.test(str)) { return str; } | ||
return str.replace(SURRORATE_SEARCH_RE, replaceBadSurrogate); | ||
} | ||
//////////////////////////////////////////////////////////////////////////////// | ||
// Incoming link can be partially encoded. Convert possible combinations to | ||
// unified form. | ||
// | ||
// TODO: Rewrite it. Should use: | ||
// | ||
// - encodeURIComponent for query | ||
// - encodeURI for path | ||
// - (?) punicode for domain mame (but encodeURI seems to work in real world) | ||
// | ||
function normalizeLink(url) { | ||
@@ -145,3 +183,5 @@ var normalized = replaceEntities(url); | ||
return encodeURI(normalized); | ||
// Encoder throws exception on broken surrogate pairs. | ||
// Fix those first. | ||
return encodeURI(fixBrokenSurrogates(normalized)); | ||
} | ||
@@ -148,0 +188,0 @@ |
@@ -21,2 +21,3 @@ // Skip text characters for text token, place those to pending buffer | ||
case 0x21/* ! */: | ||
case 0x23/* # */: | ||
case 0x26/* & */: | ||
@@ -23,0 +24,0 @@ case 0x3C/* < */: |
{ | ||
"name": "markdown-it", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"description": "Markdown-it - modern pluggable markdown parser.", | ||
@@ -40,3 +40,10 @@ "keywords": [ | ||
"jade": "^1.6.0", | ||
"markdown-it-emoji": "~ 0.1.0", | ||
"markdown-it-abbr": "~ 0.1.0", | ||
"markdown-it-deflist": "~ 0.1.0", | ||
"markdown-it-emoji": "~ 0.1.3", | ||
"markdown-it-footnote": "~ 0.1.0", | ||
"markdown-it-ins": "~ 0.1.0", | ||
"markdown-it-mark": "~ 0.1.0", | ||
"markdown-it-sub": "~ 0.1.0", | ||
"markdown-it-sup": "~ 0.1.0", | ||
"markdown-it-testgen": "~ 0.1.0", | ||
@@ -43,0 +50,0 @@ "marked": "0.3.2", |
@@ -173,3 +173,3 @@ # markdown-it | ||
Via plugins:: | ||
Via plugins: | ||
@@ -187,3 +187,3 @@ - [subscript](https://github.com/markdown-it/markdown-it-sub) | ||
By default all rules are enebled, but can be restricted by options. On plugin | ||
By default all rules are enabled, but can be restricted by options. On plugin | ||
load all it's rules are enabled automatically. | ||
@@ -190,0 +190,0 @@ |
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
546167
14663
23