From f3676789408dfaf898823c1fbe3cb7d6888a1fd4 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 19 Nov 2016 12:11:22 +0000 Subject: Add startsWith style name matcher --- lib/styles/document-matchers.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/styles/document-matchers.js b/lib/styles/document-matchers.js index 38ac049..3f7fbdd 100644 --- a/lib/styles/document-matchers.js +++ b/lib/styles/document-matchers.js @@ -6,6 +6,7 @@ exports.underline = new Matcher("underline"); exports.strikethrough = new Matcher("strikethrough"); exports.commentReference = new Matcher("commentReference"); exports.equalTo = equalTo; +exports.startsWith = startsWith; function paragraph(options) { @@ -42,11 +43,22 @@ function isList(element, levelIndex, isOrdered) { function equalTo(value) { return { - operator: equals, + operator: operatorEqualTo, operand: value }; } -function equals(first, second) { +function startsWith(value) { + return { + operator: operatorStartsWith, + operand: value + }; +} + +function operatorEqualTo(first, second) { return first.toUpperCase() === second.toUpperCase(); } + +function operatorStartsWith(first, second) { + return second.toUpperCase().indexOf(first.toUpperCase()) === 0; +} -- cgit v1.2.3