1.0.1 • Published 5 years ago

marked-mailchimp v1.0.1

Weekly downloads
5
License
ISC
Repository
github
Last release
5 years ago

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

1.0.1

5 years ago

1.0.0

5 years ago