+ // Check if the <body> tag is available.\r
+ if ( !(/<body[\s|>]/).test( data ) )\r
+ data = '<body>' + data;\r
+\r
+ // Check if the <html> tag is available.\r
+ if ( !(/<html[\s|>]/).test( data ) )\r
+ data = '<html>' + data + '</html>';\r
+\r
+ // Check if the <head> tag is available.\r
+ if ( !(/<head[\s|>]/).test( data ) )\r
+ data = data.replace( /<html[^>]*>/, '$&<head><title></title></head>' ) ;\r
+\r
+ // The base must be the first tag in the HEAD, e.g. to get relative\r
+ // links on styles.\r
+ baseTag && ( data = data.replace( /<head>/, '$&' + baseTag ) );\r
+\r
+ // Inject the extra stuff into <head>.\r
+ // Attention: do not change it before testing it well. (V2)\r
+ // This is tricky... if the head ends with <meta ... content type>,\r
+ // Firefox will break. But, it works if we place our extra stuff as\r
+ // the last elements in the HEAD.\r
+ data = data.replace( /<\/head\s*>/, headExtra + '$&' );\r
+\r
+ // Add the DOCTYPE back to it.\r
+ data = docType + data;\r