Skip to content

Commit

Permalink
Replace % with pc in output HTML class names.
Browse files Browse the repository at this point in the history
% would need escaping, and Gmail doesn't support that.
  • Loading branch information
cossssmin committed Feb 1, 2020
1 parent dc8e0ab commit 4b90d7a
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/generators/output/toString.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,18 @@ module.exports = async (str, options) => {
}

html = html
.replace(/(\..+)(\\:|\\\/)/g, group => group.replace(/\\:|\\\//g, '-')) // replace \/ and \: in class names from head
.replace(/class\s*=\s*["'][^"']*[/:][^"']*["']/g, group => group.replace(/\/|:/g, '-')) // replace special characters in class names from body
// Rewrite class names in `<head>` CSS
.replace(/(\..+)(\\:|\\\/|\\%)/g, group => {
return group
.replace(/\\:|\\\//g, '-') // replace `\/` and `\:` with `-`
.replace(/\\%/g, 'pc') // replace `%` with `pc`
})
// Rewrite class names in `<body>` HTML
.replace(/class\s*=\s*["'][^"']*[/:][^"']*["']/g, group => {
return group
.replace(/\/|:/g, '-') // replace `\/` and `\:` with `-`
.replace(/%/g, 'pc') // replace `%` with `pc`
})

if (typeof options.afterRender === 'function') {
html = await options.afterRender(html, config)
Expand Down

0 comments on commit 4b90d7a

Please sign in to comment.