From 189f37b6a183c6a611fc745ebad894ef3e2c7774 Mon Sep 17 00:00:00 2001 From: devlinjd Date: Sat, 10 Oct 2015 17:49:29 -0400 Subject: [PATCH] Add Markdown format support. --- src/fluentcmd.js | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/fluentcmd.js b/src/fluentcmd.js index e1d8581..dd4f0ac 100644 --- a/src/fluentcmd.js +++ b/src/fluentcmd.js @@ -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() } ]; /**