Skip to content

Jonahss/marked-mailchimp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Fixes code formatting within mailchimp emails, for users of the marked markdown renderer

Resources

Stars

Watchers

Forks

Packages

No packages published