Last active
June 6, 2016 18:09
-
-
Save tmaslen/38d0d99284d857b4f6e7cd104484c22b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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