const prefix = "md-"; const selectall = `${prefix}dl`; const renderer = { // Block-level methods code(code, infostring, escaped) { return `
${code}
`; }, blockquote(quote) { return `
${quote}
`; }, html(html, block) { return block ? html : `${html}`; }, heading(text, level, raw, slugger) { return `${text}`; }, hr() { return `
`; }, list(body, ordered, start) { const tag = ordered ? 'ol' : 'ul'; return `<${tag} class="${selectall} ${prefix}list ${prefix}${tag}"${ordered && start !== 1 ? ` start="${start}"` : ''}>${body}`; }, listitem(text, task, checked) { let classList = `${prefix}li`; if(task) { classList += ` ${prefix}li-checkbox`; } else { classList += ` ${prefix}li-nocheckbox`; } return `
  • ${text}
  • `; }, checkbox(checked) { return ``; }, paragraph(text) { return `

    ${text}

    `; }, table(header, body) { return `${header}${body}
    `; }, tablerow(content) { return `${content}`; }, tablecell(content, flags) { const type = flags.header ? 'th' : 'td'; return `<${type} class="${selectall} ${prefix}${type}">${content}`; }, // Inline-level methods strong(text) { return `${text}`; }, em(text) { return `${text}`; }, codespan(code) { return `${code}`; }, br() { return `
    `; }, del(text) { return `${text}`; }, link(href, title, text) { return `${text}`; }, image(href, title, text) { return `${text}`; }, text(text) { return text; // text-level elements typically don't have classes }, }; const hooks = { postprocess(html) { return `
    ${html}
    `; }, preprocess(md) { return md; } }; module.exports = { renderer, hooks };