1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2024-11-21 16:00:11 +00:00

fix: prevent broken XML in Word docs

This commit is contained in:
hacksalot 2018-02-06 08:22:31 -05:00
parent 7262578c81
commit 2bf5bb72cf
No known key found for this signature in database
GPG Key ID: 2F343EC247CA4B06
2 changed files with 6 additions and 3 deletions

View File

@ -6,7 +6,9 @@ Definition of the Markdown to WordProcessingML conversion routine.
*/ */
(function() { (function() {
var HTML5Tokenizer, _; var HTML5Tokenizer, XML, _;
XML = require('xml-escape');
_ = require('underscore'); _ = require('underscore');
@ -51,7 +53,7 @@ Definition of the Markdown to WordProcessingML conversion routine.
style = is_bold ? '<w:b/>' : ''; style = is_bold ? '<w:b/>' : '';
style += is_italic ? '<w:i/>' : ''; style += is_italic ? '<w:i/>' : '';
style += is_link ? '<w:rStyle w:val="Hyperlink"/>' : ''; style += is_link ? '<w:rStyle w:val="Hyperlink"/>' : '';
return final += (is_link ? '<w:hlink w:dest="' + link_url + '">' : '') + '<w:r><w:rPr>' + style + '</w:rPr><w:t>' + tok.chars + '</w:t></w:r>' + (is_link ? '</w:hlink>' : ''); return final += (is_link ? '<w:hlink w:dest="' + link_url + '">' : '') + '<w:r><w:rPr>' + style + '</w:rPr><w:t>' + XML(tok.chars) + '</w:t></w:r>' + (is_link ? '</w:hlink>' : '');
} }
} }
}); });

View File

@ -5,6 +5,7 @@ Definition of the Markdown to WordProcessingML conversion routine.
### ###
XML = require 'xml-escape'
_ = require 'underscore' _ = require 'underscore'
HTML5Tokenizer = require 'simple-html-tokenizer' HTML5Tokenizer = require 'simple-html-tokenizer'
@ -44,6 +45,6 @@ module.exports = ( html ) ->
style += if is_link then '<w:rStyle w:val="Hyperlink"/>' else '' style += if is_link then '<w:rStyle w:val="Hyperlink"/>' else ''
final += final +=
(if is_link then ('<w:hlink w:dest="' + link_url + '">') else '') + (if is_link then ('<w:hlink w:dest="' + link_url + '">') else '') +
'<w:r><w:rPr>' + style + '</w:rPr><w:t>' + tok.chars + '<w:r><w:rPr>' + style + '</w:rPr><w:t>' + XML(tok.chars) +
'</w:t></w:r>' + (if is_link then '</w:hlink>' else '') '</w:t></w:r>' + (if is_link then '</w:hlink>' else '')
final final