5151 * UI events.
5252 * If set to {@code false}, {@code prettyPrint()} is synchronous.
5353 */
54- var PR_SHOULD_USE_CONTINUATION = true ;
54+ window [ ' PR_SHOULD_USE_CONTINUATION' ] = true ;
5555
5656/** the number of characters between tab columns */
57- var PR_TAB_WIDTH = 8 ;
57+ window [ ' PR_TAB_WIDTH' ] = 8 ;
5858
5959/** Walks the DOM returning a properly escaped version of innerHTML.
6060 * @param {Node } node
6161 * @param {Array.<string> } out output buffer that receives chunks of HTML.
6262 */
63- var PR_normalizedHtml ;
63+ window [ ' PR_normalizedHtml' ]
6464
6565/** Contains functions for creating and registering new language handlers.
6666 * @type {Object }
6767 */
68- var PR ;
68+ = window [ 'PR' ]
6969
7070/** Pretty print a chunk of code.
7171 *
7272 * @param {string } sourceCodeHtml code as html
7373 * @return {string } code as html, but prettier
7474 */
75- var prettyPrintOne ;
75+ = window [ ' prettyPrintOne' ]
7676/** find all the < pre > and < code > tags in the DOM with class=prettyprint
7777 * and prettify them.
7878 * @param {Function } opt_whenDone if specified, called when the last entry
7979 * has been finished.
8080 */
81- var prettyPrint ;
81+ = window [ ' prettyPrint' ] = void 0 ;
8282
8383/** browser detection. @extern */
84- function _pr_isIE6 ( ) {
84+ window [ '_pr_isIE6' ] = function ( ) {
8585 var isIE6 = navigator && navigator . userAgent &&
8686 / \b M S I E 6 \. / . test ( navigator . userAgent ) ;
87- _pr_isIE6 = function ( ) { return isIE6 ; } ;
87+ window [ ' _pr_isIE6' ] = function ( ) { return isIE6 ; } ;
8888 return isIE6 ;
89- }
89+ } ;
9090
9191
9292( function ( ) {
@@ -597,7 +597,7 @@ function _pr_isIE6() {
597597 var nPatterns = fallthroughStylePatterns . length ;
598598 var notWs = / \S / ;
599599
600- return function decorate ( sourceCode , opt_basePos ) {
600+ var decorate = function ( sourceCode , opt_basePos ) {
601601 opt_basePos = opt_basePos || 0 ;
602602 var decorations = [ opt_basePos , PR_PLAIN ] ;
603603 var lastToken = '' ;
@@ -673,6 +673,7 @@ function _pr_isIE6() {
673673 }
674674 return decorations ;
675675 } ;
676+ return decorate ;
676677 }
677678
678679 var PR_MARKUP_LEXER = createSimpleLexer ( [ ] , [
@@ -769,12 +770,12 @@ function _pr_isIE6() {
769770 */
770771 function sourceDecorator ( options ) {
771772 var shortcutStylePatterns = [ ] , fallthroughStylePatterns = [ ] ;
772- if ( options . tripleQuotedStrings ) {
773+ if ( options [ ' tripleQuotedStrings' ] ) {
773774 // '''multi-line-string''', 'single-line-string', and double-quoted
774775 shortcutStylePatterns . push (
775776 [ PR_STRING , / ^ (?: \' \' \' (?: [ ^ \' \\ ] | \\ [ \s \S ] | \' { 1 , 2 } (? = [ ^ \' ] ) ) * (?: \' \' \' | $ ) | \" \" \" (?: [ ^ \" \\ ] | \\ [ \s \S ] | \" { 1 , 2 } (? = [ ^ \" ] ) ) * (?: \" \" \" | $ ) | \' (?: [ ^ \\ \' ] | \\ [ \s \S ] ) * (?: \' | $ ) | \" (?: [ ^ \\ \" ] | \\ [ \s \S ] ) * (?: \" | $ ) ) / ,
776777 null , '\'"' ] ) ;
777- } else if ( options . multiLineStrings ) {
778+ } else if ( options [ ' multiLineStrings' ] ) {
778779 // 'multi-line-string', "multi-line-string"
779780 shortcutStylePatterns . push (
780781 [ PR_STRING , / ^ (?: \' (?: [ ^ \\ \' ] | \\ [ \s \S ] ) * (?: \' | $ ) | \" (?: [ ^ \\ \" ] | \\ [ \s \S ] ) * (?: \" | $ ) | \` (?: [ ^ \\ \` ] | \\ [ \s \S ] ) * (?: \` | $ ) ) / ,
@@ -788,15 +789,15 @@ function _pr_isIE6() {
788789 }
789790 fallthroughStylePatterns . push (
790791 [ PR_PLAIN , / ^ (?: [ ^ \' \" \` \/ \# ] + ) / , null , ' \r\n' ] ) ;
791- if ( options . hashComments ) {
792+ if ( options [ ' hashComments' ] ) {
792793 shortcutStylePatterns . push ( [ PR_COMMENT , / ^ # [ ^ \r \n ] * / , null , '#' ] ) ;
793794 }
794- if ( options . cStyleComments ) {
795+ if ( options [ ' cStyleComments' ] ) {
795796 fallthroughStylePatterns . push ( [ PR_COMMENT , / ^ \/ \/ [ ^ \r \n ] * / , null ] ) ;
796797 fallthroughStylePatterns . push (
797798 [ PR_COMMENT , / ^ \/ \* [ \s \S ] * ?(?: \* \/ | $ ) / , null ] ) ;
798799 }
799- if ( options . regexLiterals ) {
800+ if ( options [ ' regexLiterals' ] ) {
800801 var REGEX_LITERAL = (
801802 // A regular expression literal starts with a slash that is
802803 // not followed by * or / so that it is not confused with
@@ -814,7 +815,7 @@ function _pr_isIE6() {
814815 [ PR_STRING , new RegExp ( REGEX_LITERAL ) , REGEXP_PRECEDER_PATTERN ] ) ;
815816 }
816817
817- var keywords = wordSet ( options . keywords ) ;
818+ var keywords = wordSet ( options [ ' keywords' ] ) ;
818819
819820 options = null ;
820821
@@ -891,11 +892,11 @@ function _pr_isIE6() {
891892 }
892893
893894 var decorateSource = sourceDecorator ( {
894- keywords : ALL_KEYWORDS ,
895- hashComments : true ,
896- cStyleComments : true ,
897- multiLineStrings : true ,
898- regexLiterals : true
895+ ' keywords' : ALL_KEYWORDS ,
896+ ' hashComments' : true ,
897+ ' cStyleComments' : true ,
898+ ' multiLineStrings' : true ,
899+ ' regexLiterals' : true
899900 } ) ;
900901
901902 /** identify attribute values that really contain source code and recursively
@@ -1010,7 +1011,7 @@ function _pr_isIE6() {
10101011 var currentDecoration = null ;
10111012 var tagPos = 0 ; // index into extractedTags
10121013 var decPos = 0 ; // index into decorations
1013- var tabExpander = makeTabExpander ( PR_TAB_WIDTH ) ;
1014+ var tabExpander = makeTabExpander ( window [ ' PR_TAB_WIDTH' ] ) ;
10141015
10151016 var adjacentSpaceRe = / ( [ \r \n ] ) / g;
10161017 var startOrSpaceRe = / ( ^ | ) / gm;
@@ -1115,46 +1116,46 @@ function _pr_isIE6() {
11151116 decorateMarkup ,
11161117 [ 'default-markup' , 'htm' , 'html' , 'mxml' , 'xhtml' , 'xml' , 'xsl' ] ) ;
11171118 registerLangHandler ( sourceDecorator ( {
1118- keywords : CPP_KEYWORDS ,
1119- hashComments : true ,
1120- cStyleComments : true
1119+ ' keywords' : CPP_KEYWORDS ,
1120+ ' hashComments' : true ,
1121+ ' cStyleComments' : true
11211122 } ) , [ 'c' , 'cc' , 'cpp' , 'cxx' , 'cyc' , 'm' ] ) ;
11221123 registerLangHandler ( sourceDecorator ( {
1123- keywords : CSHARP_KEYWORDS ,
1124- hashComments : true ,
1125- cStyleComments : true
1124+ ' keywords' : CSHARP_KEYWORDS ,
1125+ ' hashComments' : true ,
1126+ ' cStyleComments' : true
11261127 } ) , [ 'cs' ] ) ;
11271128 registerLangHandler ( sourceDecorator ( {
1128- keywords : JAVA_KEYWORDS ,
1129- cStyleComments : true
1129+ ' keywords' : JAVA_KEYWORDS ,
1130+ ' cStyleComments' : true
11301131 } ) , [ 'java' ] ) ;
11311132 registerLangHandler ( sourceDecorator ( {
1132- keywords : SH_KEYWORDS ,
1133- hashComments : true ,
1134- multiLineStrings : true
1133+ ' keywords' : SH_KEYWORDS ,
1134+ ' hashComments' : true ,
1135+ ' multiLineStrings' : true
11351136 } ) , [ 'bsh' , 'csh' , 'sh' ] ) ;
11361137 registerLangHandler ( sourceDecorator ( {
1137- keywords : PYTHON_KEYWORDS ,
1138- hashComments : true ,
1139- multiLineStrings : true ,
1140- tripleQuotedStrings : true
1138+ ' keywords' : PYTHON_KEYWORDS ,
1139+ ' hashComments' : true ,
1140+ ' multiLineStrings' : true ,
1141+ ' tripleQuotedStrings' : true
11411142 } ) , [ 'cv' , 'py' ] ) ;
11421143 registerLangHandler ( sourceDecorator ( {
1143- keywords : PERL_KEYWORDS ,
1144- hashComments : true ,
1145- multiLineStrings : true ,
1146- regexLiterals : true
1144+ ' keywords' : PERL_KEYWORDS ,
1145+ ' hashComments' : true ,
1146+ ' multiLineStrings' : true ,
1147+ ' regexLiterals' : true
11471148 } ) , [ 'perl' , 'pl' , 'pm' ] ) ;
11481149 registerLangHandler ( sourceDecorator ( {
1149- keywords : RUBY_KEYWORDS ,
1150- hashComments : true ,
1151- multiLineStrings : true ,
1152- regexLiterals : true
1150+ ' keywords' : RUBY_KEYWORDS ,
1151+ ' hashComments' : true ,
1152+ ' multiLineStrings' : true ,
1153+ ' regexLiterals' : true
11531154 } ) , [ 'rb' ] ) ;
11541155 registerLangHandler ( sourceDecorator ( {
1155- keywords : JSCRIPT_KEYWORDS ,
1156- cStyleComments : true ,
1157- regexLiterals : true
1156+ ' keywords' : JSCRIPT_KEYWORDS ,
1157+ ' cStyleComments' : true ,
1158+ ' regexLiterals' : true
11581159 } ) , [ 'js' ] ) ;
11591160
11601161 function prettyPrintOne ( sourceCodeHtml , opt_langExtension ) {
@@ -1198,7 +1199,7 @@ function _pr_isIE6() {
11981199 }
11991200
12001201 function prettyPrint ( opt_whenDone ) {
1201- var isIE6 = _pr_isIE6 ( ) ;
1202+ var isIE6 = window [ ' _pr_isIE6' ] ( ) ;
12021203
12031204 // fetch a list of nodes to rewrite
12041205 var codeSegments = [
@@ -1218,7 +1219,7 @@ function _pr_isIE6() {
12181219 var k = 0 ;
12191220
12201221 function doWork ( ) {
1221- var endTime = ( PR_SHOULD_USE_CONTINUATION ?
1222+ var endTime = ( window [ ' PR_SHOULD_USE_CONTINUATION' ] ?
12221223 new Date ( ) . getTime ( ) + 250 /* ms */ :
12231224 Infinity ) ;
12241225 for ( ; k < elements . length && new Date ( ) . getTime ( ) < endTime ; k ++ ) {
0 commit comments