diff options
Diffstat (limited to 'lib/styles')
| -rw-r--r-- | lib/styles/document-matchers.js | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/styles/document-matchers.js b/lib/styles/document-matchers.js index bdc213c..38ac049 100644 --- a/lib/styles/document-matchers.js +++ b/lib/styles/document-matchers.js @@ -5,6 +5,7 @@ exports.italic = new Matcher("italic"); exports.underline = new Matcher("underline"); exports.strikethrough = new Matcher("strikethrough"); exports.commentReference = new Matcher("commentReference"); +exports.equalTo = equalTo; function paragraph(options) { @@ -29,7 +30,7 @@ function Matcher(elementType, options) { 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._styleName === undefined || (element.styleName && this._styleName.operator(this._styleName.operand, element.styleName))) && (this._listIndex === undefined || isList(element, this._listIndex, this._listIsOrdered)); }; @@ -38,3 +39,14 @@ function isList(element, levelIndex, isOrdered) { element.numbering.level == levelIndex && element.numbering.isOrdered == isOrdered; } + +function equalTo(value) { + return { + operator: equals, + operand: value + }; +} + +function equals(first, second) { + return first.toUpperCase() === second.toUpperCase(); +} |
