maizzle / framework

Quickly build HTML emails with Tailwind CSS.
https://maizzle.com
MIT License
1.24k stars 49 forks source link

How to prevent href encoding of handlebar tags in markdown links? #427

Closed jbtheard closed 3 years ago

jbtheard commented 3 years ago

I'm using Maizzle + Sendgrid.

when I declare my markdown content, I define links with escaped variable such as [my link](http://www.@{{variable}}.com)

Expected: <a href="http://www.{{variable}}.com">my link</a>

But markdown-it encode all links so the resulting html is <a href="http://www.%7B%7Bvariable%7D%7D.com">my link</a>

How would we ensure we keep original tags? Unfortunately Transform Content is not a solution... I looked into markdown-it config but could find where to set that... (how do we disable normalizeLink rule perhaps?)

Happy to update the doc for some guidance as I guess it's quite a common case...

cossssmin commented 3 years ago

Can't find any way to disable href value encoding in markdown-it (don't think it's possible), so you can use replaceStrings in your Maizzle config instead:

module.exports = {
  replaceStrings: {
    '%7B%7B': '{{',
    '%7D%7D': '}}'
  },
}

https://maizzle.com/docs/code-cleanup/#replacestrings