Skip to content

Commit

Permalink
Use marked rather than helper-markdown
Browse files Browse the repository at this point in the history
helper-markdown depends on remarkable which has unfixed security issue
jonschlinkert/remarkable#332
  • Loading branch information
XuluWarrior committed Jun 30, 2019
1 parent 9ef0f73 commit 3920790
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 67 deletions.
23 changes: 19 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
var fs = require("fs");
var path = require('path');
var Handlebars = require("handlebars");
var markdown = require('helper-markdown');
var utils = require('handlebars-utils');
var marked = require('marked');
var moment = require('moment');

Handlebars.registerHelper('markdown', function() {
var markup = markdown().apply(this, arguments);
Handlebars.registerHelper('markdown', function(str, locals, options) {
if (typeof str !== 'string') {
options = locals;
locals = str;
str = true;
}

if (utils.isOptions(locals)) {
options = locals;
locals = {};
}

var ctx = utils.context(this, locals, options);
var val = utils.value(str, ctx, options);

var markup = marked(val);

// If we end up with a string wrapped in one <p> block, remove it so we don't create a new text block
var startEndMatch = markup.match(/^<p>(.*)<\/p>\n$/);
Expand Down Expand Up @@ -131,4 +146,4 @@ function render(resume) {

module.exports = {
render: render
};
};
79 changes: 18 additions & 61 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@
},
"dependencies": {
"handlebars": "^4.1.2",
"helper-markdown": "^1.0.0",
"handlebars-utils": "^1.0.6",
"marked": "^0.6.3",
"moment": "^2.24.0"
},
"devDependencies": {
"less": "^3.9.0"
},
"engineStrict" : true,
"engineStrict": true,
"engines": {
"node": ">=6"
}
Expand Down

0 comments on commit 3920790

Please sign in to comment.