Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function markdownObj(data) {
// string
if (_.isString(data)) {
if (data.startsWith('mailto:')) return data
// clean with detergent then parse as markdown
const cleanData = detergent(data, { addMissingSpaces: false }).res
return marked(cleanData, { renderer })
}
// error case: bad data
if (!data) {
logger.error(`Bad JSON! ${data} is not parsable as Markdown.`)
return {}
}
// array
if (_.isArray(data)) {
return data.map(markdownObj)
}
// object
return _.reduce(