diff options
| author | Michael Williamson <mike@zwobble.org> | 2024-06-13 12:02:46 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2024-06-13 12:02:46 +0100 |
| commit | 0546ccd76018d05a513fb1a1c4bb6bca42628dab (patch) | |
| tree | 13695a3e91d3491adb92b74ec681fec0176b8dee /lib/styles | |
| parent | 66c9ef99816708cb1ffedd3ec37e5622bf823c20 (diff) | |
Fix: matchers for specific break types match all break types
Diffstat (limited to 'lib/styles')
| -rw-r--r-- | lib/styles/document-matchers.js | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/styles/document-matchers.js b/lib/styles/document-matchers.js index 58c844a..e2fd63b 100644 --- a/lib/styles/document-matchers.js +++ b/lib/styles/document-matchers.js @@ -9,9 +9,9 @@ exports.allCaps = new Matcher("allCaps"); exports.smallCaps = new Matcher("smallCaps"); exports.highlight = highlight; exports.commentReference = new Matcher("commentReference"); -exports.lineBreak = new Matcher("break", {breakType: "line"}); -exports.pageBreak = new Matcher("break", {breakType: "page"}); -exports.columnBreak = new Matcher("break", {breakType: "column"}); +exports.lineBreak = new BreakMatcher({breakType: "line"}); +exports.pageBreak = new BreakMatcher({breakType: "page"}); +exports.columnBreak = new BreakMatcher({breakType: "column"}); exports.equalTo = equalTo; exports.startsWith = startsWith; @@ -61,6 +61,16 @@ HighlightMatcher.prototype.matches = function(element) { (this._color === undefined || element.color === this._color); }; +function BreakMatcher(options) { + options = options || {}; + this._breakType = options.breakType; +} + +BreakMatcher.prototype.matches = function(element) { + return element.type === "break" && + (this._breakType === undefined || element.breakType === this._breakType); +}; + function isList(element, levelIndex, isOrdered) { return element.numbering && element.numbering.level == levelIndex && |
