inline-css icon indicating copy to clipboard operation
inline-css copied to clipboard

Option to ignore certain link tags

Open sammdec opened this issue 9 years ago • 6 comments

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

sammdec avatar Jan 13 '16 13:01 sammdec

+1

andrefgneves avatar Jan 27 '16 22:01 andrefgneves

+1

halcarleton avatar Feb 02 '16 15:02 halcarleton

+1

scnroy avatar Apr 19 '16 21:04 scnroy

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)

adekbadek avatar Jun 22 '16 08:06 adekbadek

There is an option to ignore style tags now. Would this work for link tags as well?

Answer: no it does not.

jonkemp avatar Mar 25 '18 20:03 jonkemp

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);
    });

    // ...
});

aliosv avatar Jan 21 '22 16:01 aliosv