Skip to content

Instantly share code, notes, and snippets.

@tmaslen
Last active June 6, 2016 18:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tmaslen/38d0d99284d857b4f6e7cd104484c22b to your computer and use it in GitHub Desktop.
Save tmaslen/38d0d99284d857b4f6e7cd104484c22b to your computer and use it in GitHub Desktop.
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