const marked = require('marked') const createRenderer = require('./mdRenderer') const renderer = createRenderer() function parseMdAsAnchor (content) { const tokens = marked.lexer(content) const titles = tokens.filter(token => token.type === 'heading' && token.depth === 2).map(token => token.text) const linkTags = titles.map(title => { const href = title.replace(/ /g, '-') return `` }) return `${linkTags.join('\n')}` } module.exports = function (content) { return ` ${marked(content, { renderer })} ${parseMdAsAnchor(content)} ` }