1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2024-06-30 23:40:05 +01:00

Add Markdown format support.

This commit is contained in:
devlinjd 2015-10-10 17:49:29 -04:00
parent 6e4263e58c
commit 189f37b6a1

View File

@ -49,7 +49,8 @@ module.exports = function () {
( (dst && dst.length && dst) || ['resume.all'] ).forEach( function(t) {
var to = path.resolve(t), pa = path.parse(to), fmat = pa.ext || '.all';
targets.push.apply(targets, fmat === '.all' ?
_fmts.map(function(z){ return to.replace(/all$/g,z.name); }) : [to]);
_fmts.map(function(z){ return { file: to.replace(/all$/g,z.ext), fmt: z } })
: [{ file: to, fmt: z }]);
});
// Run the transformation!
@ -64,19 +65,12 @@ module.exports = function () {
@param f Full path to the destination resume to generate, for example,
"/foo/bar/resume.pdf" or "c:\foo\bar\resume.txt".
*/
function single( f ) {
function single( fi ) {
try {
// Get the output file type (pdf, html, txt, etc)
var fType = path.extname( f ).trim().toLowerCase().substr(1);
var fName = path.basename( f, '.' + fType );
// Get the format object (if any) corresponding to that type, and assemble
// the final output file path for the generated resume.
var fObj = _fmts.filter( function(_f) { return _f.name === fType; } )[0];
var f = fi.file, fType = fi.fmt.ext, fName = path.basename( f, '.' + fType );
var fObj = _fmts.filter( function(_f) { return _f.ext === fType; } )[0];
var fOut = path.join( f.substring( 0, f.lastIndexOf('.') + 1 ) + fObj.ext );
// Generate!
_log( 'Generating ' + fType.toUpperCase() + ' resume: ' + path.relative(process.cwd(), f) );
_log( 'Generating ' + fi.fmt.name.toUpperCase() + ' resume: ' + path.relative(process.cwd(), f ) );
return fObj.gen.generate( rez, fOut, _opts.theme );
}
catch( ex ) {
@ -98,7 +92,8 @@ module.exports = function () {
{ name: 'html', ext: 'html', gen: new FLUENT.HtmlGenerator() },
{ name: 'txt', ext: 'txt', gen: new FLUENT.TextGenerator() },
{ name: 'doc', ext: 'doc', fmt: 'xml', gen: new FLUENT.WordGenerator() },
{ name: 'pdf', ext: 'pdf', fmt: 'html', is: false, gen: new FLUENT.HtmlPdfGenerator() }
{ name: 'pdf', ext: 'pdf', fmt: 'html', is: false, gen: new FLUENT.HtmlPdfGenerator() },
{ name: 'markdown', ext: 'md', fmt: 'txt', gen: new FLUENT.MarkdownGenerator() }
];
/**