From 0546ccd76018d05a513fb1a1c4bb6bca42628dab Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Thu, 13 Jun 2024 12:02:46 +0100 Subject: Fix: matchers for specific break types match all break types --- lib/styles/document-matchers.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'lib/styles') 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 && -- cgit v1.2.3