inline-css
inline-css copied to clipboard
Option to ignore certain link tags
It would be a neat feature if we could somehow tell inline-css to ignore certain <link>
tags e.g. Google fonts link tag.
This would mean it leaves it as is on the page and skips over it
+1
+1
+1
It throws this error when HTML has a google font link:
Unhandled rejection Error: Bad Request
at Request.callback (path/to/project/node_modules/superagent/lib/node/index.js:698:17)
at Stream.<anonymous> (path/to/project/node_modules/superagent/lib/node/index.js:922:12)
at emitNone (events.js:72:20)
at Stream.emit (events.js:166:7)
at Unzip.<anonymous> (path/to/project/node_modules/superagent/lib/node/utils.js:108:12)
at emitNone (events.js:72:20)
at Unzip.emit (events.js:166:7)
at endReadableNT (_stream_readable.js:905:12)
at doNTCallback2 (node.js:441:9)
at process._tickCallback (node.js:355:17)
(I'm using the gulp plugin but I guess the issue is with inline-css
itself)
There is an option to ignore style tags now. Would this work for link tags as well?
Answer: no it does not.
For the same problem i did like this
// find "link" tags which we want to save
let fontLinks = html.match(/<link[^>]+?fonts\.googleapis\.com[^>]+?>/g) || [];
// replace them with custom tag
fontLinks.forEach(function(value, index) {
html = html.replace(value, '<fontlink' + index + '>');
});
// inline css
inlineCss(html, {}).then(function(styledHtml) {
// return our "link" tags back
fontLinks.forEach(function(value, index) {
styledHtml = styledHtml.replace('<fontlink' + index + '>', value);
});
// ...
});