|
@ -9,22 +9,21 @@ var StateInline = require('./rules_inline/state_inline'); |
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
// Parser rules
|
|
|
// Parser rules
|
|
|
|
|
|
|
|
|
var rules = []; |
|
|
var _rules = []; |
|
|
|
|
|
|
|
|
|
|
|
_rules.push(require('./rules_inline/text')); |
|
|
// Pure text
|
|
|
_rules.push(require('./rules_inline/newline')); |
|
|
rules.push(require('./rules_inline/text')); |
|
|
_rules.push(require('./rules_inline/escape')); |
|
|
rules.push(require('./rules_inline/newline')); |
|
|
_rules.push(require('./rules_inline/backticks')); |
|
|
rules.push(require('./rules_inline/escape')); |
|
|
_rules.push(require('./rules_inline/del')); |
|
|
rules.push(require('./rules_inline/backticks')); |
|
|
_rules.push(require('./rules_inline/ins')); |
|
|
rules.push(require('./rules_inline/del')); |
|
|
_rules.push(require('./rules_inline/mark')); |
|
|
rules.push(require('./rules_inline/ins')); |
|
|
_rules.push(require('./rules_inline/emphasis')); |
|
|
rules.push(require('./rules_inline/mark')); |
|
|
_rules.push(require('./rules_inline/links')); |
|
|
rules.push(require('./rules_inline/emphasis')); |
|
|
_rules.push(require('./rules_inline/autolink')); |
|
|
rules.push(require('./rules_inline/links')); |
|
|
_rules.push(require('./rules_inline/htmltag')); |
|
|
rules.push(require('./rules_inline/autolink')); |
|
|
_rules.push(require('./rules_inline/entity')); |
|
|
rules.push(require('./rules_inline/htmltag')); |
|
|
|
|
|
rules.push(require('./rules_inline/entity')); |
|
|
|
|
|
|
|
|
|
|
|
var BAD_PROTOCOLS = [ 'vbscript', 'javascript', 'file' ]; |
|
|
var BAD_PROTOCOLS = [ 'vbscript', 'javascript', 'file' ]; |
|
|
|
|
|
|
|
@ -58,8 +57,8 @@ function ParserInline() { |
|
|
|
|
|
|
|
|
this.ruler = new Ruler(this.rulesUpdate.bind(this)); |
|
|
this.ruler = new Ruler(this.rulesUpdate.bind(this)); |
|
|
|
|
|
|
|
|
for (var i = 0; i < rules.length; i++) { |
|
|
for (var i = 0; i < _rules.length; i++) { |
|
|
this.ruler.after(rules[i]); |
|
|
this.ruler.after(_rules[i]); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -74,7 +73,6 @@ ParserInline.prototype.rulesUpdate = function () { |
|
|
//
|
|
|
//
|
|
|
ParserInline.prototype.skipToken = function (state) { |
|
|
ParserInline.prototype.skipToken = function (state) { |
|
|
var i, cached_pos, pos = state.pos, |
|
|
var i, cached_pos, pos = state.pos, |
|
|
rules = this._rules, |
|
|
|
|
|
len = this._rules.length; |
|
|
len = this._rules.length; |
|
|
|
|
|
|
|
|
if ((cached_pos = state.cacheGet(pos)) > 0) { |
|
|
if ((cached_pos = state.cacheGet(pos)) > 0) { |
|
@ -83,7 +81,7 @@ ParserInline.prototype.skipToken = function (state) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
for (i = 0; i < len; i++) { |
|
|
for (i = 0; i < len; i++) { |
|
|
if (rules[i](state, true)) { |
|
|
if (this._rules[i](state, true)) { |
|
|
state.cacheSet(pos, state.pos); |
|
|
state.cacheSet(pos, state.pos); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
@ -98,7 +96,6 @@ ParserInline.prototype.skipToken = function (state) { |
|
|
//
|
|
|
//
|
|
|
ParserInline.prototype.tokenize = function (state) { |
|
|
ParserInline.prototype.tokenize = function (state) { |
|
|
var ok, i, |
|
|
var ok, i, |
|
|
rules = this._rules, |
|
|
|
|
|
len = this._rules.length, |
|
|
len = this._rules.length, |
|
|
end = state.posMax; |
|
|
end = state.posMax; |
|
|
|
|
|
|
|
@ -112,7 +109,7 @@ ParserInline.prototype.tokenize = function (state) { |
|
|
// - return true
|
|
|
// - return true
|
|
|
|
|
|
|
|
|
for (i = 0; i < len; i++) { |
|
|
for (i = 0; i < len; i++) { |
|
|
ok = rules[i](state, false); |
|
|
ok = this._rules[i](state, false); |
|
|
if (ok) { break; } |
|
|
if (ok) { break; } |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|