1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2025-05-10 15:57:07 +01:00

Improve Markdown support for JSON Resume themes.

This commit is contained in:
hacksalot
2015-12-29 10:01:45 -05:00
parent 02ef2b2241
commit 483207e5a0
2 changed files with 89 additions and 1 deletions

View File

@ -3,6 +3,7 @@
var PATH = require('path')
, FS = require('fs')
, parsePath = require('parse-filepath')
, MD = require('marked')
, MKDIRP = require('mkdirp')
, _opts = require('../core/default-options')
, FluentTheme = require('../core/theme')
@ -102,6 +103,11 @@
"/foo/bar/resume.pdf" or "c:\foo\bar\resume.txt".
*/
function single( targInfo, theme ) {
function MDIN(txt) {
return MD(txt || '' ).replace(/^\s*<p>|<\/p>\s*$/gi, '');
}
try {
var f = targInfo.file
, fType = targInfo.fmt.outFormat
@ -144,7 +150,24 @@
// return PATH.join(p2, p1);
// }
});
var rezHtml = theme.render( rez );
// Prevent JSON Resume theme .js from chattering
var consoleLog = console.log;
console.log = function() { };
// Call the theme's render method
var rezDupe = rez.harden();
var rezHtml = theme.render( rezDupe );
// Turn logging back on
console.log = consoleLog;
// Unharden
rezHtml = rezHtml.replace( /@@@@~.+?~@@@@/g, function(val){
return MDIN( val.replace( /~@@@@/gm,'' ).replace( /@@@@~/gm,'' ) );
});
// Save the file
FS.writeFileSync( f, rezHtml );
}
else {