From a12b966752ba7ae880f7d6348a42cc986e891a82 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Mon, 28 Nov 2016 21:08:40 +0000 Subject: Map breaks with style maps --- lib/document-to-html.js | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'lib/document-to-html.js') diff --git a/lib/document-to-html.js b/lib/document-to-html.js index a51afd0..3a30ed2 100644 --- a/lib/document-to-html.js +++ b/lib/document-to-html.js @@ -283,6 +283,23 @@ function DocumentConversion(options, comments) { ]; } + function convertBreak(element, messages) { + return htmlPathForBreak(element).wrap(function() { + return []; + }); + } + + function htmlPathForBreak(element) { + var style = findStyle(element); + if (style) { + return style.to; + } else if (element.breakType === "line") { + return htmlPaths.topLevelElement("br"); + } else { + return htmlPaths.empty; + } + } + function wrapChildrenInFreshElement(element, wrapElementName, messages) { var children = convertElements(element.children, messages); return [ @@ -349,13 +366,7 @@ function DocumentConversion(options, comments) { "table": convertTable, "tableRow": convertTableRow, "tableCell": convertTableCell, - "break": function(element, messages) { - if (element.breakType === "line") { - return [Html.freshElement("br")]; - } else { - return []; - } - } + "break": convertBreak }; return { convertToHtml: convertToHtml -- cgit v1.2.3