From 2bf5bb72cff1c9e16df292270b1e19aff51a03d1 Mon Sep 17 00:00:00 2001 From: hacksalot Date: Tue, 6 Feb 2018 08:22:31 -0500 Subject: [PATCH] fix: prevent broken XML in Word docs --- dist/utils/html-to-wpml.js | 6 ++++-- src/utils/html-to-wpml.coffee | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/dist/utils/html-to-wpml.js b/dist/utils/html-to-wpml.js index bef0dd6..6feb07f 100644 --- a/dist/utils/html-to-wpml.js +++ b/dist/utils/html-to-wpml.js @@ -6,7 +6,9 @@ Definition of the Markdown to WordProcessingML conversion routine. */ (function() { - var HTML5Tokenizer, _; + var HTML5Tokenizer, XML, _; + + XML = require('xml-escape'); _ = require('underscore'); @@ -51,7 +53,7 @@ Definition of the Markdown to WordProcessingML conversion routine. style = is_bold ? '' : ''; style += is_italic ? '' : ''; style += is_link ? '' : ''; - return final += (is_link ? '' : '') + '' + style + '' + tok.chars + '' + (is_link ? '' : ''); + return final += (is_link ? '' : '') + '' + style + '' + XML(tok.chars) + '' + (is_link ? '' : ''); } } }); diff --git a/src/utils/html-to-wpml.coffee b/src/utils/html-to-wpml.coffee index 98cb1b5..f8e5b7e 100644 --- a/src/utils/html-to-wpml.coffee +++ b/src/utils/html-to-wpml.coffee @@ -5,6 +5,7 @@ Definition of the Markdown to WordProcessingML conversion routine. ### +XML = require 'xml-escape' _ = require 'underscore' HTML5Tokenizer = require 'simple-html-tokenizer' @@ -44,6 +45,6 @@ module.exports = ( html ) -> style += if is_link then '' else '' final += (if is_link then ('') else '') + - '' + style + '' + tok.chars + + '' + style + '' + XML(tok.chars) + '' + (if is_link then '' else '') final