diff --git a/lib/styles/document-matchers.js b/lib/styles/document-matchers.js index 58c844a3..e2fd63b1 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 && diff --git a/test/document-to-html.tests.js b/test/document-to-html.tests.js index 4587602f..a18c4f5e 100644 --- a/test/document-to-html.tests.js +++ b/test/document-to-html.tests.js @@ -655,12 +655,18 @@ test('breaks can be mapped using style mappings', function() { { from: documentMatchers.pageBreak, to: htmlPaths.topLevelElement("hr") + }, + { + from: documentMatchers.lineBreak, + to: htmlPaths.topLevelElement("br", {class: "line-break"}) } ] }); - return converter.convertToHtml(documents.pageBreak).then(function(result) { - assert.equal(result.value, "