2016-01-27 10:29:26 +00:00
|
|
|
(function() {
|
2018-02-12 05:05:29 +00:00
|
|
|
/**
|
|
|
|
Definition of the JRSGenerator class.
|
|
|
|
@license MIT. See LICENSE.md for details.
|
|
|
|
@module renderers/jrs-generator
|
|
|
|
*/
|
|
|
|
/**
|
|
|
|
Perform template-based resume generation for JSON Resume themes.
|
|
|
|
@class JRSGenerator
|
|
|
|
*/
|
2016-01-27 10:29:26 +00:00
|
|
|
var FS, HANDLEBARS, JRSGenerator, MD, MDIN, PATH, READFILES, SLASH, _, parsePath, registerHelpers;
|
|
|
|
|
|
|
|
_ = require('underscore');
|
|
|
|
|
|
|
|
HANDLEBARS = require('handlebars');
|
|
|
|
|
|
|
|
FS = require('fs');
|
|
|
|
|
|
|
|
registerHelpers = require('../helpers/handlebars-helpers');
|
|
|
|
|
|
|
|
PATH = require('path');
|
|
|
|
|
|
|
|
parsePath = require('parse-filepath');
|
|
|
|
|
|
|
|
READFILES = require('recursive-readdir-sync');
|
|
|
|
|
|
|
|
SLASH = require('slash');
|
|
|
|
|
|
|
|
MD = require('marked');
|
|
|
|
|
|
|
|
JRSGenerator = module.exports = {
|
|
|
|
generate: function(json, jst, format, cssInfo, opts, theme) {
|
|
|
|
var org, rezHtml, turnoff;
|
2018-02-12 05:05:29 +00:00
|
|
|
// Disable JRS theme chatter (console.log, console.error, etc.)
|
2016-01-27 10:29:26 +00:00
|
|
|
turnoff = ['log', 'error', 'dir'];
|
2016-01-30 16:31:39 +00:00
|
|
|
org = turnoff.map(function(c) {
|
2016-01-27 10:29:26 +00:00
|
|
|
var ret;
|
|
|
|
ret = console[c];
|
2016-01-30 16:31:39 +00:00
|
|
|
console[c] = function() {};
|
|
|
|
return ret;
|
2016-01-27 10:29:26 +00:00
|
|
|
});
|
2018-02-12 05:05:29 +00:00
|
|
|
// Freeze and render
|
2016-01-27 10:29:26 +00:00
|
|
|
rezHtml = theme.render(json.harden());
|
2018-02-12 05:05:29 +00:00
|
|
|
// Turn logging back on
|
2016-01-27 10:29:26 +00:00
|
|
|
turnoff.forEach(function(c, idx) {
|
|
|
|
return console[c] = org[idx];
|
|
|
|
});
|
2018-02-12 05:05:29 +00:00
|
|
|
// Unfreeze and apply Markdown
|
2018-02-03 21:15:17 +00:00
|
|
|
return rezHtml = rezHtml.replace(/@@@@~[\s\S]*?~@@@@/g, function(val) {
|
|
|
|
return MDIN(val.replace(/~@@@@/g, '').replace(/@@@@~/g, ''));
|
2016-01-27 10:29:26 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-02-12 05:05:29 +00:00
|
|
|
MDIN = function(txt) { // TODO: Move this
|
2016-01-27 10:29:26 +00:00
|
|
|
return MD(txt || '').replace(/^\s*<p>|<\/p>\s*$/gi, '');
|
|
|
|
};
|
|
|
|
|
|
|
|
}).call(this);
|
2016-02-02 02:14:36 +00:00
|
|
|
|
|
|
|
//# sourceMappingURL=jrs-generator.js.map
|