aboutsummaryrefslogtreecommitdiff
path: root/lib/styles
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2016-11-19 12:03:32 +0000
committerMichael Williamson <mike@zwobble.org>2016-11-19 12:03:32 +0000
commit6bef85a8fde03b50de4aa78064ab4c32ad54041c (patch)
tree84bc1ab1c337f0ca045b1cb34487ec07f4c84c76 /lib/styles
parent68d8c8140fb6ef1118fa2815243817f8e4f55b59 (diff)
Introduce matcher for style name
Diffstat (limited to 'lib/styles')
-rw-r--r--lib/styles/document-matchers.js14
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();
+}