Vitaly Puzrin
10 years ago
6 changed files with 59 additions and 15 deletions
@ -0,0 +1,49 @@ |
|||
// Class of link replacement rules
|
|||
//
|
|||
'use strict'; |
|||
|
|||
|
|||
var assign = require('./common/utils').assign; |
|||
var Ruler = require('./ruler'); |
|||
|
|||
|
|||
var rules = [ |
|||
require('./rules_text/linkify') |
|||
]; |
|||
|
|||
|
|||
function Linkifier() { |
|||
this._rules = []; |
|||
|
|||
this.options = {}; |
|||
|
|||
this.ruler = new Ruler(this.rulesUpdate.bind(this)); |
|||
|
|||
for (var i = 0; i < rules.length; i++) { |
|||
this.ruler.after(rules[i]); |
|||
} |
|||
} |
|||
|
|||
|
|||
Linkifier.prototype.rulesUpdate = function () { |
|||
this._rules = this.ruler.getRules(); |
|||
}; |
|||
|
|||
|
|||
Linkifier.prototype.set = function (options) { |
|||
assign(this.options, options); |
|||
}; |
|||
|
|||
|
|||
Linkifier.prototype.process = function (state) { |
|||
var i, l, rules; |
|||
|
|||
rules = this._rules; |
|||
|
|||
for (i = 0, l = rules.length; i < l; i++) { |
|||
rules[i](this, state); |
|||
} |
|||
}; |
|||
|
|||
|
|||
module.exports = Linkifier; |
Loading…
Reference in new issue