Browse Source

reorganized files

pull/14/head
Vitaly Puzrin 10 years ago
parent
commit
0930235149
  1. 8
      lib/index.js
  2. 49
      lib/linkifier.js
  3. 0
      lib/rules_text/linkify.js
  4. 0
      lib/rules_text/replace.js
  5. 0
      lib/rules_text/smartquotes.js
  6. 17
      lib/typographer.js

8
lib/index.js

@ -8,6 +8,7 @@ var Renderer = require('./renderer');
var ParserBlock = require('./parser_block');
var ParserInline = require('./parser_inline');
var Typographer = require('./typographer');
var Linkifier = require('./linkifier');
var defaults = require('./defaults/remarkable');
@ -25,12 +26,7 @@ function Remarkable(options) {
this.block = new ParserBlock();
this.renderer = new Renderer();
this.typographer = new Typographer();
this.linkifier = new Typographer();
// Linkifier is a separate typographer, for convenience.
// Configure it here.
this.linkifier.ruler.enable([], true);
this.linkifier.ruler.after(require('./rules_typographer/linkify'));
this.linkifier = new Linkifier();
// Cross-references to simplify code (a bit dirty, but easy).
this.block.inline = this.inline;

49
lib/linkifier.js

@ -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;

0
lib/rules_typographer/linkify.js → lib/rules_text/linkify.js

0
lib/rules_typographer/replace.js → lib/rules_text/replace.js

0
lib/rules_typographer/smartquotes.js → lib/rules_text/smartquotes.js

17
lib/typographer.js

@ -1,4 +1,4 @@
// Class of typographic replacements rules
// Class of typographic replacement rules
//
'use strict';
@ -7,16 +7,15 @@
// - miltiplication 2 x 4 -> 2 × 4
var defaults = require('./defaults/typographer');
var assign = require('./common/utils').assign;
var Ruler = require('./ruler');
var defaults = require('./defaults/typographer');
var assign = require('./common/utils').assign;
var Ruler = require('./ruler');
var rules = [];
rules.push(require('./rules_typographer/replace'));
rules.push(require('./rules_typographer/smartquotes'));
var rules = [
require('./rules_text/replace'),
require('./rules_text/smartquotes')
];
function Typographer() {

Loading…
Cancel
Save