aboutsummaryrefslogtreecommitdiff
path: root/lib/document-matchers.js
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2016-11-19 11:54:43 +0000
committerMichael Williamson <mike@zwobble.org>2016-11-19 11:54:43 +0000
commit68d8c8140fb6ef1118fa2815243817f8e4f55b59 (patch)
treed4e4be8d3b124d98f2d204ed5f97585a8729ca94 /lib/document-matchers.js
parent5f84e7887b262b96fd6fd47ce6bb1cd96c196f69 (diff)
Move html-paths and document-matchers to styles module
Diffstat (limited to 'lib/document-matchers.js')
-rw-r--r--lib/document-matchers.js40
1 files changed, 0 insertions, 40 deletions
diff --git a/lib/document-matchers.js b/lib/document-matchers.js
deleted file mode 100644
index bdc213c..0000000
--- a/lib/document-matchers.js
+++ /dev/null
@@ -1,40 +0,0 @@
-exports.paragraph = paragraph;
-exports.run = run;
-exports.bold = new Matcher("bold");
-exports.italic = new Matcher("italic");
-exports.underline = new Matcher("underline");
-exports.strikethrough = new Matcher("strikethrough");
-exports.commentReference = new Matcher("commentReference");
-
-
-function paragraph(options) {
- return new Matcher("paragraph", options);
-}
-
-function run(options) {
- return new Matcher("run", options);
-}
-
-function Matcher(elementType, options) {
- options = options || {};
- this._elementType = elementType;
- this._styleId = options.styleId;
- this._styleName = options.styleName;
- if (options.list) {
- this._listIndex = options.list.levelIndex;
- this._listIsOrdered = options.list.isOrdered;
- }
-}
-
-Matcher.prototype.matches = function(element) {
- return element.type === this._elementType &&
- (this._styleId === undefined || element.styleId === this._styleId) &&
- (this._styleName === undefined || (element.styleName && element.styleName.toUpperCase() === this._styleName.toUpperCase())) &&
- (this._listIndex === undefined || isList(element, this._listIndex, this._listIsOrdered));
-};
-
-function isList(element, levelIndex, isOrdered) {
- return element.numbering &&
- element.numbering.level == levelIndex &&
- element.numbering.isOrdered == isOrdered;
-}