diff options
| author | Michael Williamson <mike@zwobble.org> | 2016-11-19 12:11:22 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2016-11-19 12:11:22 +0000 |
| commit | f3676789408dfaf898823c1fbe3cb7d6888a1fd4 (patch) | |
| tree | 5129ae6ac59ae7349f64f35bb05c24d79e4c6a34 /lib | |
| parent | 6bef85a8fde03b50de4aa78064ab4c32ad54041c (diff) | |
Add startsWith style name matcher
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/styles/document-matchers.js | 16 |
1 files changed, 14 insertions, 2 deletions
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; +} |
