javascript - Is there any good tool or plug-in to convert all externally imported css into inline styles?
某草草2017-05-18 10:53:51
0
4
718
As we all know, emails must have inline styles to take effect. All external styles of web pages must be converted into internal styles called email templates. Are there any good plug-ins?
html-packer can take html's <script>, <link>, and <img> (including *.svg sources) tags into html-self. More than that, it also can compress to minimize it.
I have never tried it. From the introduction, this plug-in seems to work. It is said that it can not only convert css, but also pictures and svg. Test it yourself. . .
I don’t know about the plug-in But you can put the css into any editor and then replace the text with regular expressions just change the style to the internal style format
For example:
.inner {
width: 300px,
height: 500px
}
First go to the classname line: .*{n and replace it with the ``null character.*{n 替换为``空字符 在去掉 } 为 空 然后匹配 ^s* 为 " 去: 为= 去nRemove} to be empty Then match ^s* to "
go to : for =
go to n ...style="width=300;height=500px"
Until it becomes the format you want for the inline style:
If there are not many tags, just copy and add them one by one.
If there are a lot of tags, write all the above processes into js, match the corresponding tags through classname, and add the corresponding styles
By the way
Isn’t this what you call a template plug-in script
It’s better to ask for others than to ask for yourself🎜
🎜goodluck🎜
https://github.com/Rozbo/html...
html-packer can take html's <script>, <link>, and <img> (including *.svg sources) tags into html-self.
More than that, it also can compress to minimize it.
I have never tried it. From the introduction, this plug-in seems to work. It is said that it can not only convert css, but also pictures and svg. Test it yourself. . .
https://www.google.com/#safe=...
There are a lot of them on github. . Why don’t you google it
This should help you, gulp plug-in
gulp-inline-css
https://www.npmjs.com/package...
I don’t know about the plug-in
But you can put the css into any editor
and then replace the text with regular expressions
just change the style to the internal style format
For example:
First go to the classname line:
go to.*{n
and replace it with the ``null character.*{n
替换为``空字符在去掉 } 为 空
然后匹配
^s*
为"
去
:
为=
去
n
Remove} to be emptyThen match
^s*
to"
:
for=
go to
Until it becomes the format you want for the inline style:n
...
style="width=300;height=500px"
If there are not many tags, just copy and add them one by one.If there are a lot of tags,
By the waywrite all the above processes into js, match the corresponding tags through classname, and add the corresponding styles
Isn’t this what you call a template plug-in script
It’s better to ask for others than to ask for yourself🎜 🎜goodluck🎜