split html instead of global regex match.  fixes issues where
duplicated resources were not getting replaced in minified code.  also
makes it easier to grok what regex is doing.
saner identation