This repository was archived by the owner on Apr 22, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +33
-9
lines changed
Expand file tree Collapse file tree 4 files changed +33
-9
lines changed Original file line number Diff line number Diff line change @@ -571,7 +571,10 @@ var prettyPrint;
571571 // If that does turn out to be a problem, we should change the below
572572 // when hc is truthy to include # in the run of punctuation characters
573573 // only when not followint [|&;<>].
574- / ^ .[ ^ \s \w \. $ @ \' \" \` \/ \\ ] * / ;
574+ '^.[^\\s\\w.$@\'"`/\\\\]*' ;
575+ if ( options [ 'regexLiterals' ] ) {
576+ punctuation += '(?!\s*\/)' ;
577+ }
575578
576579 fallthroughStylePatterns . push (
577580 // TODO(mikesamuel): recognize non-latin letters and numerals in idents
@@ -591,9 +594,10 @@ var prettyPrint;
591594 // with an optional modifier like UL for unsigned long
592595 + '[a-z]*' , 'i' ) ,
593596 null , '0123456789' ] ,
594- // Don't treat escaped quotes in bash as starting strings. See issue 144.
597+ // Don't treat escaped quotes in bash as starting strings.
598+ // See issue 144.
595599 [ PR_PLAIN , / ^ \\ [ \s \S ] ? / , null ] ,
596- [ PR_PUNCTUATION , punctuation , null ] ) ;
600+ [ PR_PUNCTUATION , new RegExp ( punctuation ) , null ] ) ;
597601
598602 return createSimpleLexer ( shortcutStylePatterns , fallthroughStylePatterns ) ;
599603 }
Original file line number Diff line number Diff line change @@ -926,7 +926,10 @@ var prettyPrint;
926926 // If that does turn out to be a problem, we should change the below
927927 // when hc is truthy to include # in the run of punctuation characters
928928 // only when not followint [|&;<>].
929- / ^ .[ ^ \s \w \. $ @ \' \" \` \/ \\ ] * / ;
929+ '^.[^\\s\\w.$@\'"`/\\\\]*' ;
930+ if ( options [ 'regexLiterals' ] ) {
931+ punctuation += '(?!\s*\/)' ;
932+ }
930933
931934 fallthroughStylePatterns . push (
932935 // TODO(mikesamuel): recognize non-latin letters and numerals in idents
@@ -946,9 +949,10 @@ var prettyPrint;
946949 // with an optional modifier like UL for unsigned long
947950 + '[a-z]*' , 'i' ) ,
948951 null , '0123456789' ] ,
949- // Don't treat escaped quotes in bash as starting strings. See issue 144.
952+ // Don't treat escaped quotes in bash as starting strings.
953+ // See issue 144.
950954 [ PR_PLAIN , / ^ \\ [ \s \S ] ? / , null ] ,
951- [ PR_PUNCTUATION , punctuation , null ] ) ;
955+ [ PR_PUNCTUATION , new RegExp ( punctuation ) , null ] ) ;
952956
953957 return createSimpleLexer ( shortcutStylePatterns , fallthroughStylePatterns ) ;
954958 }
Original file line number Diff line number Diff line change @@ -1115,7 +1115,10 @@ var IN_GLOBAL_SCOPE = false;
11151115 // If that does turn out to be a problem, we should change the below
11161116 // when hc is truthy to include # in the run of punctuation characters
11171117 // only when not followint [|&;<>].
1118- / ^ .[ ^ \s \w \. $ @ \' \" \` \/ \\ ] * / ;
1118+ '^.[^\\s\\w.$@\'"`/\\\\]*' ;
1119+ if ( options [ 'regexLiterals' ] ) {
1120+ punctuation += '(?!\s*\/)' ;
1121+ }
11191122
11201123 fallthroughStylePatterns . push (
11211124 // TODO(mikesamuel): recognize non-latin letters and numerals in idents
@@ -1135,9 +1138,10 @@ var IN_GLOBAL_SCOPE = false;
11351138 // with an optional modifier like UL for unsigned long
11361139 + '[a-z]*' , 'i' ) ,
11371140 null , '0123456789' ] ,
1138- // Don't treat escaped quotes in bash as starting strings. See issue 144.
1141+ // Don't treat escaped quotes in bash as starting strings.
1142+ // See issue 144.
11391143 [ PR_PLAIN , / ^ \\ [ \s \S ] ? / , null ] ,
1140- [ PR_PUNCTUATION , punctuation , null ] ) ;
1144+ [ PR_PUNCTUATION , new RegExp ( punctuation ) , null ] ) ;
11411145
11421146 return createSimpleLexer ( shortcutStylePatterns , fallthroughStylePatterns ) ;
11431147 }
Original file line number Diff line number Diff line change @@ -818,6 +818,13 @@ <h1>LLVM</h1>
818818!foo = !{!1, null}
819819</ pre >
820820
821+ < h1 > Issue 217 : Regex following '!'</ h1 >
822+ < pre id ="issue217 " class ="prettyprint lang-js ">
823+ if(!/^https?:\/\//i.test(val) && foo == 'bar') {
824+ val = 'http://' + val;
825+ }
826+ </ pre >
827+
821828</ body>
822829
823830< script type ="text/javascript ">
@@ -1530,6 +1537,11 @@ <h1>LLVM</h1>
15301537 '`END`COM; Named metadata`END`PLN\n' +
15311538 '!1 `END`PUN=`END`PLN `END`KWDmetadata`END`PLN !`END`PUN{`END`KWDi32`END`PLN `END`LIT42`END`PUN}`END`PLN\n' +
15321539 '!foo `END`PUN=`END`PLN !`END`PUN{`END`PLN!1`END`PUN,`END`PLN `END`KWDnull`END`PUN}`END'
1540+ ) ,
1541+ issue217 : (
1542+ '`KWDif`END`PUN(!`END`STR/^https?:\\/\\//`END`PLNi`END`PUN.`END`PLNtest`END`PUN(`END`PLNval`END`PUN)`END`PLN `END`PUN&&`END`PLN foo `END`PUN==`END`PLN `END`STR\'bar\'`END`PUN)`END`PLN `END`PUN{`END`PLN\n' +
1543+ ' val `END`PUN=`END`PLN `END`STR\'http://\'`END`PLN `END`PUN+`END`PLN val`END`PUN;`END`PLN\n' +
1544+ '`END`PUN}`END'
15331545 )
15341546} ;
15351547</ script >
You can’t perform that action at this time.
0 commit comments