|
|
@ -15,7 +15,7 @@ function StateInline(src, parser, options, env) { |
|
|
|
this.pending = ''; |
|
|
|
this.pendingLevel = 0; |
|
|
|
|
|
|
|
this.cache = {}; // Stores { start: end } pairs. Useful for backtrack
|
|
|
|
this.cache = []; // Stores { start: end } pairs. Useful for backtrack
|
|
|
|
// optimization of pairs parse (emphasis, strikes).
|
|
|
|
|
|
|
|
// Link parser state vars
|
|
|
@ -34,6 +34,8 @@ function StateInline(src, parser, options, env) { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Flush pending text
|
|
|
|
//
|
|
|
|
StateInline.prototype.pushPending = function () { |
|
|
|
this.tokens.push({ |
|
|
|
type: 'text', |
|
|
@ -43,6 +45,10 @@ StateInline.prototype.pushPending = function () { |
|
|
|
this.pending = ''; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// Push new token to "stream".
|
|
|
|
// If pending text exists - flush it as text token
|
|
|
|
//
|
|
|
|
StateInline.prototype.push = function (token) { |
|
|
|
if (this.pending) { |
|
|
|
this.pushPending(); |
|
|
@ -53,4 +59,24 @@ StateInline.prototype.push = function (token) { |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// 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; |
|
|
|