remarkable
Advanced tools
Comparing version 1.1.1 to 1.1.2
@@ -0,1 +1,10 @@ | ||
1.1.2 / 2014-10-23 | ||
------------------ | ||
- Fixed speed regression. | ||
- Use base64 encoding for permalinks (workaround for github). | ||
- Improved default link validator. | ||
- Updated cache storage logic for inline parser. | ||
1.1.1 / 2014-10-22 | ||
@@ -5,3 +14,3 @@ ------------------ | ||
- Fixed `Ruler.after()` method. | ||
- Fixed linkification | ||
- Fixed linkification. | ||
- Simplified loose/tight rendering. | ||
@@ -8,0 +17,0 @@ - Refactored inline parser. No close coupled code in rules anymore. |
@@ -10,3 +10,3 @@ | ||
function parseLinkLabel(state, start) { | ||
var level, found, marker, ok, | ||
var level, found, marker, | ||
labelEnd = -1, | ||
@@ -40,5 +40,3 @@ max = state.posMax, | ||
ok = state.parser.skipToken(state); | ||
if (!ok) { state.pos++; } | ||
state.parser.skipToken(state); | ||
} | ||
@@ -45,0 +43,0 @@ |
@@ -20,3 +20,3 @@ // Inline parser | ||
rules.push(require('./rules_inline/backticks')); | ||
rules.push(require('./rules_inline/strikethrough')); | ||
rules.push(require('./rules_inline/del')); | ||
rules.push(require('./rules_inline/emphasis')); | ||
@@ -29,4 +29,16 @@ rules.push(require('./rules_inline/links')); | ||
var BAD_PROTOCOLS = [ 'vbscript', 'javascript', 'file' ]; | ||
function validateLink(url) { | ||
if (url.indexOf('javas' + 'cript:') === 0) { return false; } | ||
var str = ''; | ||
try { | ||
str = decodeURI(url).trim().toLowerCase(); | ||
} catch (_) {} | ||
if (!str) { return false; } | ||
if (str.indexOf(':') >= 0 && BAD_PROTOCOLS.indexOf(str.split(':')[0]) >= 0) { | ||
return false; | ||
} | ||
return true; | ||
@@ -66,9 +78,9 @@ } | ||
ParserInline.prototype.skipToken = function (state) { | ||
var i, pos = state.pos, | ||
var i, cached_pos, pos = state.pos, | ||
rules = this._rules, | ||
len = this._rules.length; | ||
if (state.cache[pos] !== undefined) { | ||
state.pos = state.cache[pos]; | ||
return true; | ||
if ((cached_pos = state.cacheGet(pos)) > 0) { | ||
state.pos = cached_pos; | ||
return; | ||
} | ||
@@ -78,8 +90,9 @@ | ||
if (rules[i](state, true)) { | ||
state.cache[pos] = state.pos; | ||
return true; | ||
state.cacheSet(pos, state.pos); | ||
return; | ||
} | ||
} | ||
return false; | ||
state.pos++; | ||
state.cacheSet(pos, state.pos); | ||
}; | ||
@@ -86,0 +99,0 @@ |
@@ -71,3 +71,16 @@ // Lists | ||
function markTightParagraphs(state, idx) { | ||
var i, l, | ||
level = state.level + 2; | ||
for (i = idx + 2, l = state.tokens.length - 2; i < l; i++) { | ||
if (state.tokens[i].level === level && state.tokens[i].type === 'paragraph_open') { | ||
state.tokens[i + 2].tight = true; | ||
state.tokens[i].tight = true; | ||
i += 2; | ||
} | ||
} | ||
} | ||
module.exports = function list(state, startLine, endLine, silent) { | ||
@@ -94,3 +107,3 @@ var nextLine, | ||
terminatorRules = state.parser._rulesListTerm, | ||
i, l, terminate, level, tokens; | ||
i, l, terminate; | ||
@@ -252,12 +265,3 @@ // Detect list type and position after marker | ||
if (tight) { | ||
level = state.level + 2; | ||
tokens = state.tokens; | ||
for (i = listTokIdx + 2, l = tokens.length - 2; i < l; i++) { | ||
if (tokens[i].level === level && tokens[i].type === 'paragraph_open') { | ||
tokens[i].tight = true; | ||
i += 2; | ||
tokens[i].tight = true; | ||
} | ||
} | ||
markTightParagraphs(state, listTokIdx); | ||
} | ||
@@ -264,0 +268,0 @@ |
@@ -115,3 +115,3 @@ // Process *this* and _that_ | ||
if (!state.parser.skipToken(state)) { state.pos++; } | ||
state.parser.skipToken(state); | ||
} | ||
@@ -118,0 +118,0 @@ |
@@ -21,2 +21,3 @@ // Process [links](<to> "stuff") | ||
isImage = false, | ||
oldPos = state.pos, | ||
max = state.posMax, | ||
@@ -90,3 +91,3 @@ start = state.pos, | ||
if (pos >= max || state.src.charCodeAt(pos) !== 0x29/* ) */) { | ||
state.pos = labelStart - 1; | ||
state.pos = oldPos; | ||
return false; | ||
@@ -126,3 +127,3 @@ } | ||
if (!ref) { | ||
state.pos = labelStart - 1; | ||
state.pos = oldPos; | ||
return false; | ||
@@ -129,0 +130,0 @@ } |
@@ -18,3 +18,3 @@ // Inline parser state | ||
this.cache = {}; // Stores { start: end } pairs. Useful for backtrack | ||
this.cache = []; // Stores { start: end } pairs. Useful for backtrack | ||
// optimization of pairs parse (emphasis, strikes). | ||
@@ -38,2 +38,4 @@ | ||
// Flush pending text | ||
// | ||
StateInline.prototype.pushPending = function () { | ||
@@ -48,2 +50,6 @@ this.tokens.push({ | ||
// Push new token to "stream". | ||
// If pending text exists - flush it as text token | ||
// | ||
StateInline.prototype.push = function (token) { | ||
@@ -59,2 +65,22 @@ if (this.pending) { | ||
// Store value to cache. | ||
// !!! Implementation has parser-specific optimizations | ||
// !!! keys MUST be integer, >= 0; values MUST be integer, > 0 | ||
// | ||
StateInline.prototype.cacheSet = function (key, val) { | ||
for (var i = this.cache.length; i <= key; i++) { | ||
this.cache.push(0); | ||
} | ||
this.cache[key] = val; | ||
}; | ||
// Get cache value | ||
// | ||
StateInline.prototype.cacheGet = function (key) { | ||
return key < this.cache.length ? this.cache[key] : 0; | ||
}; | ||
module.exports = StateInline; |
{ | ||
"name": "remarkable", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "Markdown parser, done right. Commonmark support, extensions, syntax plugins, high speed - all in one.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -137,4 +137,4 @@ remarkable | ||
- [Strikethrough](https://help.github.com/articles/github-flavored-markdown/#strikethrough) | ||
- [Tables](https://help.github.com/articles/github-flavored-markdown/#tables) (GFM) | ||
- [\<del>](https://help.github.com/articles/github-flavored-markdown/#strikethrough) (GFM strikethrough) - `~~deleted text~~` | ||
@@ -141,0 +141,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
443728
12376