aboutsummaryrefslogtreecommitdiff
path: root/lib/document-matchers.js
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2014-04-22 13:38:46 +0100
committerMichael Williamson <mike@zwobble.org>2014-04-22 13:38:46 +0100
commitec837dc5c639efa92fb676dc90c008ad7cfff58e (patch)
tree44e50cb6713b22f91d7972fa8cfa83ee88cec58b /lib/document-matchers.js
parent58ae1397f2a603a98adef5589763d9af2da636cb (diff)
Simplify document matcher parsing
Diffstat (limited to 'lib/document-matchers.js')
-rw-r--r--lib/document-matchers.js28
1 files changed, 22 insertions, 6 deletions
diff --git a/lib/document-matchers.js b/lib/document-matchers.js
index f116d3f..0846513 100644
--- a/lib/document-matchers.js
+++ b/lib/document-matchers.js
@@ -1,18 +1,34 @@
+var _ = require("underscore");
+
exports.paragraph = paragraph;
exports.run = run;
-function paragraph(styleId) {
- return new Matcher("paragraph", styleId);
+function paragraph(options) {
+ options = options || {};
+ if (_.isString(options)) {
+ // TODO: this is deprecated, remove usages
+ options = {styleId: options};
+ }
+ return new Matcher("paragraph", options);
}
-function run(styleId) {
- return new Matcher("run", styleId);
+function run(options) {
+ options = options || {};
+ if (_.isString(options)) {
+ // TODO: this is deprecated, remove usages
+ options = {styleId: options};
+ }
+ return new Matcher("run", options);
}
-function Matcher(elementType, styleId) {
+function Matcher(elementType, options) {
this._elementType = elementType;
- this._styleId = styleId;
+ this._styleId = options.styleId;
+ if (options.list) {
+ this._listIndex = options.list.levelIndex;
+ this._listIsOrdered = options.list.isOrdered;
+ }
}
Matcher.prototype.matches = function(element) {