1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2025-05-04 05:17:08 +01:00

Improve XML encoding for Word docs.

Fix various encoding errors.
This commit is contained in:
hacksalot
2015-12-31 06:38:30 -05:00
parent 069c02ddcc
commit b85d40b1b3
4 changed files with 93 additions and 4 deletions

View File

@ -9,6 +9,7 @@ Generic template helper definitions for HackMyResume / FluentCV.
var MD = require('marked')
, H2W = require('../utils/html-to-wpml')
, XML = require('xml-escape')
, moment = require('moment')
, _ = require('underscore');
@ -33,10 +34,12 @@ Generic template helper definitions for HackMyResume / FluentCV.
wpml: function( txt, inline ) {
if(!txt) return '';
inline = (inline && !inline.hash) || false;
txt = XML(txt.trim());
txt = inline ?
MD(txt.trim()).replace(/^\s*<p>|<\/p>\s*$/gi, '') :
MD(txt.trim());
txt = H2W( txt.trim() );
MD(txt).replace(/^\s*<p>|<\/p>\s*$/gi, '') :
MD(txt);
txt = H2W( txt );
console.log(txt);
return txt;
},

View File

@ -35,8 +35,13 @@ Definition of the HandlebarsGenerator class.
// Compile and run the Handlebars template.
var template = HANDLEBARS.compile(jst);
var encData = json;
( format === 'html' || format === 'pdf' ) && (encData = json.markdownify());
( format === 'doc' ) && (encData = json.xmlify());
return template({
r: format === 'html' || format === 'pdf' || format === 'png' ? json.markdownify() : json,
r: encData,
RAW: json,
filt: opts.filters,
cssInfo: cssInfo,