(function (root, factory) { 'use strict'; /*global define*/ if (typeof define === 'function' && define.amd) { define(factory()); } else if (typeof exports === 'object') { module.exports = factory(); } else { root.htmlFromBin = factory(); } })(this, function htmlFromBin() { 'use strict'; var doctypeRe = new RegExp(/^]*>\n?/im); function insert(source, needle, value, options) { if (source.toLowerCase().indexOf(needle.toLowerCase()) === -1) { return null; } if (!options) { options = {}; } var left = source.substring(0, source.toLowerCase().lastIndexOf(needle.toLowerCase())); var right = source.substring(source.toLowerCase().lastIndexOf(needle.toLowerCase())); // var parts = source.split(needle); // var last = parts.pop(); var result = ''; if (left && right) { // Add it just after before the end head tag if we can if (options.after) { result = left + needle + value + right; } else { result = left + value + '\n' + needle + right; } } return result; } function safeForHTML(s) { return s.replace(/<\/script/gi, '<\\/script').replace(/\n'; /** * 1. strip the doctype and print it then add comment (