@@ -90,12 +90,13 @@ window['PR_normalizedHtml']
9090 */
9191 = window [ 'prettyPrint' ] = void 0 ;
9292
93- /** browser detection. @extern */
93+ /** browser detection. @extern @returns false if not IE, otherwise the major version. */
9494window [ '_pr_isIE6' ] = function ( ) {
95- var isIE6 = navigator && navigator . userAgent &&
96- / \b M S I E 6 \. / . test ( navigator . userAgent ) ;
97- window [ '_pr_isIE6' ] = function ( ) { return isIE6 ; } ;
98- return isIE6 ;
95+ var ieVersion = navigator && navigator . userAgent &&
96+ navigator . userAgent . match ( / \b M S I E ( [ 6 7 8 ] ) \. / ) ;
97+ ieVersion = ieVersion ? + ieVersion [ 1 ] : false ;
98+ window [ '_pr_isIE6' ] = function ( ) { return ieVersion ; } ;
99+ return ieVersion ;
99100} ;
100101
101102
@@ -1319,7 +1320,9 @@ window['_pr_isIE6'] = function () {
13191320 }
13201321
13211322 function prettyPrint ( opt_whenDone ) {
1322- var isIE6 = window [ '_pr_isIE6' ] ( ) ;
1323+ var isIE678 = window [ '_pr_isIE6' ] ( ) ;
1324+ var ieNewline = isIE678 === 6 ? '\r\n' : '\r' ;
1325+ // See bug 71 and http://stackoverflow.com/questions/136443/why-doesnt-ie7-
13231326
13241327 // fetch a list of nodes to rewrite
13251328 var codeSegments = [
@@ -1431,12 +1434,12 @@ window['_pr_isIE6'] = function () {
14311434 // Doing this on other browsers breaks lots of stuff since \r\n is
14321435 // treated as two newlines on Firefox, and doing this also slows
14331436 // down rendering.
1434- if ( isIE6 && cs . tagName === 'PRE' ) {
1437+ if ( isIE678 && cs . tagName === 'PRE' ) {
14351438 var lineBreaks = cs . getElementsByTagName ( 'br' ) ;
14361439 for ( var j = lineBreaks . length ; -- j >= 0 ; ) {
14371440 var lineBreak = lineBreaks [ j ] ;
14381441 lineBreak . parentNode . replaceChild (
1439- document . createTextNode ( '\r' ) , lineBreak ) ;
1442+ document . createTextNode ( ieNewline ) , lineBreak ) ;
14401443 }
14411444 }
14421445 }
0 commit comments