markdown-it
Advanced tools
Comparing version 9.0.0 to 9.0.1
@@ -0,1 +1,7 @@ | ||
9.0.1 / 2019-07-12 | ||
------------------ | ||
- Fix possible corruption of open/close tag levels, #466 | ||
9.0.0 / 2019-07-09 | ||
@@ -2,0 +8,0 @@ ------------------ |
@@ -260,2 +260,27 @@ // Utilities | ||
// | ||
// Simple .toLowerCase() doesn't normalize 125 code points correctly, | ||
// and .toUpperCase doesn't normalize 6 of them (list of exceptions: | ||
// İ, ϴ, ẞ, Ω, K, Å - those are already uppercased, but have differently | ||
// uppercased versions). | ||
// | ||
// Here's an example showing how it happens. Lets take greek letter omega: | ||
// uppercase U+0398 (Θ), U+03f4 (ϴ) and lowercase U+03b8 (θ), U+03d1 (ϑ) | ||
// | ||
// Unicode entries: | ||
// 0398;GREEK CAPITAL LETTER THETA;Lu;0;L;;;;;N;;;;03B8; | ||
// 03B8;GREEK SMALL LETTER THETA;Ll;0;L;;;;;N;;;0398;;0398 | ||
// 03D1;GREEK THETA SYMBOL;Ll;0;L;<compat> 03B8;;;;N;GREEK SMALL LETTER SCRIPT THETA;;0398;;0398 | ||
// 03F4;GREEK CAPITAL THETA SYMBOL;Lu;0;L;<compat> 0398;;;;N;;;;03B8; | ||
// | ||
// Case-insensitive comparison should treat all of them as equivalent. | ||
// | ||
// But .toLowerCase() doesn't change ϑ (it's already lowercase), | ||
// and .toUpperCase() doesn't change ϴ (already uppercase). | ||
// | ||
// Applying first lower then upper case normalizes any character: | ||
// '\u0398\u03f4\u03b8\u03d1'.toLowerCase().toUpperCase() === '\u0398\u0398\u0398\u0398' | ||
// | ||
// Note: this is equivalent to unicode case folding; unicode normalization | ||
// is a different step that is not required here. | ||
// | ||
// Final result should be uppercased, because it's later stored in an object | ||
@@ -262,0 +287,0 @@ // (this avoid a conflict with Object.prototype members, |
@@ -114,5 +114,5 @@ // Parser state class | ||
if (nesting < 0) { this.level--; } | ||
if (nesting < 0) this.level--; // closing tag | ||
token.level = this.level; | ||
if (nesting > 0) { this.level++; } | ||
if (nesting > 0) this.level++; // opening tag | ||
@@ -119,0 +119,0 @@ this.tokens.push(token); |
@@ -53,5 +53,5 @@ // Inline parser state | ||
if (nesting < 0) { this.level--; } | ||
if (nesting < 0) this.level--; // closing tag | ||
token.level = this.level; | ||
if (nesting > 0) { this.level++; } | ||
if (nesting > 0) this.level++; // opening tag | ||
@@ -58,0 +58,0 @@ this.pendingLevel = this.level; |
@@ -1,3 +0,9 @@ | ||
// Merge adjacent text nodes into one, and re-calculate all token levels | ||
// Clean up tokens after emphasis and strikethrough postprocessing: | ||
// merge adjacent text nodes into one and re-calculate all token levels | ||
// | ||
// This is necessary because initially emphasis delimiter markers (*, _, ~) | ||
// are treated as their own separate text tokens. Then emphasis rule either | ||
// leaves them as text (needed to merge with adjacent text) or turns them | ||
// into opening/closing tags (which messes up levels inside). | ||
// | ||
'use strict'; | ||
@@ -13,5 +19,7 @@ | ||
for (curr = last = 0; curr < max; curr++) { | ||
// re-calculate levels | ||
level += tokens[curr].nesting; | ||
// re-calculate levels after emphasis/strikethrough turns some text nodes | ||
// into opening/closing tags | ||
if (tokens[curr].nesting < 0) level--; // closing tag | ||
tokens[curr].level = level; | ||
if (tokens[curr].nesting > 0) level++; // opening tag | ||
@@ -18,0 +26,0 @@ if (tokens[curr].type === 'text' && |
{ | ||
"name": "markdown-it", | ||
"version": "9.0.0", | ||
"version": "9.0.1", | ||
"description": "Markdown-it - modern pluggable markdown parser.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
553072
11997