marked-mailchimp

1.0.1 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i marked-mailchimp

Weekly Downloads

0

Version

1.0.1

License

ISC

Unpacked Size

3.04 kB

Total Files

4

Last publish

Collaborators

  • jlipps
  • jonahss