diff options
| author | Michael Williamson <mike@zwobble.org> | 2015-06-17 15:40:21 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2015-06-17 15:40:21 +0100 |
| commit | a52d99fd85061a9f20b481535407a225d5927434 (patch) | |
| tree | 6cea0c2d11a263a959df251eb7be1af2455b6440 /lib | |
| parent | dc53892204989de1788081624c65062dc283480a (diff) | |
Allow strikethrough to be configured in style mapping
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/document-matchers.js | 1 | ||||
| -rw-r--r-- | lib/document-to-html.js | 11 | ||||
| -rw-r--r-- | lib/style-reader.js | 4 |
3 files changed, 14 insertions, 2 deletions
diff --git a/lib/document-matchers.js b/lib/document-matchers.js index a4d59be..a03e335 100644 --- a/lib/document-matchers.js +++ b/lib/document-matchers.js @@ -1,6 +1,7 @@ exports.paragraph = paragraph; exports.run = run; exports.underline = new Matcher("underline"); +exports.strikethrough = new Matcher("strikethrough"); function paragraph(options) { diff --git a/lib/document-to-html.js b/lib/document-to-html.js index f424acf..907d62c 100644 --- a/lib/document-to-html.js +++ b/lib/document-to-html.js @@ -126,7 +126,7 @@ function DocumentConversion(options) { convertUnderline(runHtml); } if (run.isStrikethrough) { - runHtml.open(htmlPaths.element("s")); + convertStrikethrough(runHtml); } convertElements(run.children, runHtml, messages, function(err) { if (err) { @@ -143,6 +143,15 @@ function DocumentConversion(options) { (options.convertUnderline || defaultConvertUnderline)(runHtml); } + function convertStrikethrough(runHtml) { + var style = findStyle({type: "strikethrough"}); + if (style) { + runHtml.appendPath(style.to); + } else { + runHtml.open(htmlPaths.element("s")); + } + } + function defaultConvertUnderline(runHtml) { var style = findStyle({type: "underline"}); if (style) { diff --git a/lib/style-reader.js b/lib/style-reader.js index 811e06e..2560971 100644 --- a/lib/style-reader.js +++ b/lib/style-reader.js @@ -121,10 +121,12 @@ function documentMatcherRule() { }); var underline = identifierToConstant("u", documentMatchers.underline); + var strikethrough = identifierToConstant("strike", documentMatchers.strikethrough); return lop.rules.firstOf("element type", paragraphOrRun, - underline + underline, + strikethrough ); } |
