Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
var _ = require( 'lodash' );
module.exports = function ( html ) {
var anyInlineCssTag = new RegExp( '<style type="text/css">[^<]*</style>', 'g' );
var matches = html.match( anyInlineCssTag );
_.uniq( matches ).forEach( function( styleTag ) {
var htmlWithOutStyleTag = html.split( styleTag );
html = htmlWithOutStyleTag[ 0 ] + styleTag + htmlWithOutStyleTag.splice( 1 ).join( '' );
});
return html;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment