marked-mailchimp
v1.0.1
Published
Fixes code formatting within mailchimp emails, for users of the marked markdown renderer
Downloads
2
Readme
This module provides a custom renderer for marked which fixes a bug in how Mailchimp renders code snippets.
Mailchimp seems to auto-indent raw html, which messes up the spacing in <pre>
elements.
This module hacks around this bug by inserting <span>
elements in front of whitespace which have a left margin.
Usage:
let marked = require('marked')
let { highlightAuto } = require('highlight.js');
let MailchimpRenderer = require('marked-mailchimp')
function highlight(code, lang) {
return highlightAuto(code, lang.length ? [lang] : null).value;
}
let opts = {
spacesPerIndent: 4,
pixelsPerIndent: 30
}
marked.setOptions({
renderer: MailchimpRenderer(marked, opts),
highlight: highlight
})
spacesPerIndent
defaults to 4
pixesPerIndent
defaults to 30