forked from alexseman/remarkable
-
Notifications
You must be signed in to change notification settings - Fork 0
/
parser_core.js
54 lines (47 loc) · 1.27 KB
/
parser_core.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import Ruler from './ruler';
import block from './rules_core/block';
import abbr from './rules_core/abbr';
import references from './rules_core/references';
import inline from './rules_core/inline';
import footnote_tail from './rules_core/footnote_tail';
import abbr2 from './rules_core/abbr2';
import replacements from './rules_core/replacements';
import smartquotes from './rules_core/smartquotes';
/**
* Core parser `rules`
*/
var _rules = [
[ 'block', block ],
[ 'abbr', abbr ],
[ 'references', references ],
[ 'inline', inline ],
[ 'footnote_tail', footnote_tail ],
[ 'abbr2', abbr2 ],
[ 'replacements', replacements ],
[ 'smartquotes', smartquotes ],
];
/**
* Class for top level (`core`) parser rules
*
* @api private
*/
export default function Core() {
this.options = {};
this.ruler = new Ruler();
for (var i = 0; i < _rules.length; i++) {
this.ruler.push(_rules[i][0], _rules[i][1]);
}
}
/**
* Process rules with the given `state`
*
* @param {Object} `state`
* @api private
*/
Core.prototype.process = function (state) {
var i, l, rules;
rules = this.ruler.getRules('');
for (i = 0, l = rules.length; i < l; i++) {
rules[i](state);
}
};