Skip to content

Commit

Permalink
Use old renderer for Mailchimp em tags
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcL committed Nov 7, 2019
1 parent 340417f commit 77a2a8e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ const marked = require('marked');
// https://mailchimp.com/help/all-the-merge-tags-cheat-sheet/
const isMailChimpTag = text => /\|(.+?)\|/.test(text);

const originalRenderer = new marked.Renderer();

const createHtmlFromMarkdown = (content, keepMailChimpTags = true) => {
const newRenderer = new marked.Renderer();

newRenderer.em = text =>
keepMailChimpTags && isMailChimpTag(text)
? `*${text}*`
: `<em>${text}</em>`;
: originalRenderer.em(text);

return marked(content, {
renderer: newRenderer,
Expand Down

0 comments on commit 77a2a8e

Please sign in to comment.