feat(courses): Add view helpers

This commit is contained in:
Khaled Garbaya
2017-09-26 17:52:10 +02:00
committed by Benedikt Rötsch
parent c650dd3f1c
commit 500b103c03
7 changed files with 32 additions and 5 deletions

17
helpers.js Normal file
View File

@@ -0,0 +1,17 @@
const marked = require('marked')
// Parse markdown text
exports.markdown = (content) => {
return marked(removeIvalidDataURL(content), {sanitize: true})
}
// Dump is a handy debugging function we can use to sort of "console.log" our data
exports.dump = (obj) => JSON.stringify(obj, null, 2)
// Evil users might try to add base64 url data to execute js
// so we should take care of that
function removeIvalidDataURL (content) {
let regex = /data:\S+;base64\S*/gm
return content.replace(regex, '#')
}