Warning, /frameworks/syntax-highlighting/autotests/folding/highlight.js.fold is written in an unsupported language. File is not indexed.
0001 #! shebang 0002 #! no-shebang 0003 0004 <beginfold id='1'>/*</beginfold id='1'> comment <endfold id='1'>*/</endfold id='1'> 0005 0006 function fun() 0007 <beginfold id='2'>{</beginfold id='2'> 0008 var boo = <beginfold id='2'>{</beginfold id='2'> 'key': <beginfold id='3'>[</beginfold id='3'> 1, 2.0, 3.0e1, 004, 0x5 <endfold id='3'>]</endfold id='3'> <endfold id='2'>}</endfold id='2'>; 0009 <endfold id='2'>}</endfold id='2'> 0010 0011 class MyClass; // reserved keywords 0012 0013 // Member objects: text after "." 0014 object.property instanceof Number; 0015 iden1.iden2 . iden3.class class; 0016 0017 var escapes = "aa\b\n\0a\"a\x12a\32a\u{123}a\$\%\ \#\y\aaa\ 0018 aaa"; 0019 var octal = 0o124; 0020 var bin = 0b1010; 0021 0022 日本語().ლಠ益ಠლ.ñá = 42; 0023 δ /No-Regex/ 0024 0025 // Only highlight valid regular expressions, of a single line, after strings 0026 // See: https://github.com/microsoft/TypeScript-TmLanguage/issues/786 0027 "text" /No-Regex 0028 "text" /Regex[:)]*/; 0029 const a = "6" / 2; <beginfold id='1'>/*</beginfold id='1'>comment<endfold id='1'>*/</endfold id='1'> const b = 5; 0030 console.log("4" / "2"); // 2 0031 // Single quote 0032 const a = '6' / 2; <beginfold id='1'>/*</beginfold id='1'>comment<endfold id='1'>*/</endfold id='1'> const b = 5; 0033 console.log('4' / '2'); // 2 0034 // Template 0035 const a = <beginfold id='4'>`</beginfold id='4'>6<endfold id='4'>`</endfold id='4'> / 2; <beginfold id='1'>/*</beginfold id='1'>comment<endfold id='1'>*/</endfold id='1'> const b = 5; 0036 console.log(<beginfold id='4'>`</beginfold id='4'>4<endfold id='4'>`</endfold id='4'> / <beginfold id='4'>`</beginfold id='4'>2<endfold id='4'>`</endfold id='4'>); // 2 0037 0038 // Built-in 0039 const os = require('os'); 0040 JSON.stringify("hello"); 0041 console.error("hello"); 0042 Math.LOG10E; 0043 Number.MAX_SAFE_INTEGER; 0044 String.raw<beginfold id='4'>`</beginfold id='4'>raw text \.\n${}<endfold id='4'>`</endfold id='4'> 0045 0046 // Tagged template literals 0047 tagFunc<beginfold id='4'>`</beginfold id='4'> 0048 Hello world! 0049 ${ alert("Hello!"); }<endfold id='4'>`</endfold id='4'>; 0050 obj.something.tagFunc<beginfold id='4'>`</beginfold id='4'>Setting ${setting} is ${value + 5}!<endfold id='4'>`</endfold id='4'>; 0051 0052 <beginfold id='1'>/*</beginfold id='1'> 0053 NOTE: The words "todo", "fixme" and "note" should be rendered in a different style 0054 within comments, match should be caseless (to test for regexp insensitive attribute). 0055 The regex used for this rule is <endfold id='1'>*/</endfold id='1'> 0056 String = /\b(?:fixme|todo|note)\b/ 0057 <beginfold id='1'>/*</beginfold id='1'> Thus, for example "Notebook" is not caught by 0058 this rule. (the "?:" in the subpattern is there to avoid the regex engine wasting time 0059 saving a backref, which is not used for anything. I do not know if the overhead of parsing 0060 that is greater than the time saved by not capturing the text...) 0061 The rule for catching these words is placed in a context "Comment common", which is used 0062 by both comment contexts (single line, multiline) using the new "IncludeRules" item. 0063 <endfold id='1'>*/</endfold id='1'> 0064 0065 // test if regex support works - nice with new fallthrough prop in context:) 0066 somestring.replace( /dooh/ , "bah!"); 0067 re=/foo/ig; // hehe 0068 0069 somestring.search( 0070 /^foo\w+\s\d{0,15}$/ 0071 ); 0072 0073 re = 0074 /dooh/; 0075 0076 // This is supposedly legal: 0077 re = somebool ? /foo/ : /bar/; 0078 0079 // NOTE - Special case: an empty regex, not a comment. 0080 // The rule uses a positive lookahead assertion to catch it: "//(?=;)". 0081 re = //; 0082 re = /a|b/; 0083 0084 <beginfold id='1'>/*</beginfold id='1'> 0085 Tests for the regex parser. 0086 It will parse classes, quanitfiers, special characters and regex operaters, 0087 as specified in the netscape documentation for javascript. 0088 Regexps are only parsed in their clean form, as the RegExp(string) constructor 0089 is using a quoted string. 0090 TODO: Find out if more regex feats should be supported. 0091 Consider using more itemDatas - assertion, quantifier are options. 0092 <endfold id='1'>*/</endfold id='1'> 0093 0094 re = /^text\s+\d+\s*$/; 0095 re = /a pattern with caret \(^\) in it/; 0096 re = /(\d{0,4})\D/; 0097 re = /[a-zA-Z_]+/; 0098 re = /[^\d^]+/; 0099 re = /\s+?\w+\.$/; 0100 re = /\/\//; 0101 re = /a|b/; 0102 0103 // the following are not regexps in E4X (=xml embedded into JavaScript) 0104 var p = <p>Hello World</p> 0105 var p = /</ 0106 var p = />/ 0107 0108 // a test if #pop back from a comment will work 0109 re = <beginfold id='1'>/*</beginfold id='1'>/foo/<endfold id='1'>*/</endfold id='1'> /bar/; 0110 // ^ POP 0111 // ^ we got back after pop in comment, if there is regexp attribs here :-) 0112 0113 <beginfold id='1'>/*</beginfold id='1'> 0114 Some tests if the fallthrough works. 0115 The fallthrough happens if a regexp is not found in a possible (!) position, 0116 which is after "search(" or "replace(" or "=" or "?" or ":" in version 0.1 of the xml file 0117 <endfold id='1'>*/</endfold id='1'> 0118 0119 var foo = 'bar'; 0120 // ^ fallthrough! 0121 0122 0123 somestring.replace( new RegExp("\\b\\w+\\b"), "word: $1"); 0124 // ^ fallthrough expected. ("new" whould be bold) 0125 0126 0127 something.method = 0128 function ( a, b, c ) <beginfold id='2'>{</beginfold id='2'> <beginfold id='1'>/*</beginfold id='1'> ... <endfold id='1'>*/</endfold id='1'> <endfold id='2'>}</endfold id='2'> 0129 // ^ fallthrough ?! 0130 0131 something.other = 0132 function ( d, e, f ) <beginfold id='2'>{</beginfold id='2'> <beginfold id='1'>/*</beginfold id='1'> ... <endfold id='1'>*/</endfold id='1'> <endfold id='2'>}</endfold id='2'> 0133 // fallthrough expected at col 0 ("function" should be bold) 0134 0135 var ary = new Array(5); 0136 // ^ fallthrough ? (if keyword is correctly rendered) 0137 0138 var b = a ? 1 : 0; 0139 // ^ ^ fallthroughs. numbers must be rendered correctly. 0140 0141 var c = d ? true : false; 0142 0143 var conditinalstring = b ? 0144 "something" : 0145 "something else"; 0146 // guess... 0147 0148 0149 <beginfold id='1'>/*</beginfold id='1'> 0150 Normal program flow... 0151 <endfold id='1'>*/</endfold id='1'> 0152 0153 if (something) 0154 dostuff(); 0155 else 0156 dont(); 0157 0158 return; 0159 0160 try <beginfold id='2'>{</beginfold id='2'> bla() <endfold id='2'>}</endfold id='2'> catch (e) <beginfold id='2'>{</beginfold id='2'> alert("ERROR! : " + e) <endfold id='2'>}</endfold id='2'> 0161 0162 for (int i=0; i < j; i++) 0163 document.write("i is" + i + "<br>"); 0164 0165 while (something) 0166 <beginfold id='2'>{</beginfold id='2'> 0167 block(); 0168 picky: 0169 if (!1) 0170 break; 0171 else 0172 continue; 0173 <endfold id='2'>}</endfold id='2'> 0174 0175 with (a) <beginfold id='2'>{</beginfold id='2'> 0176 do <beginfold id='2'>{</beginfold id='2'> 0177 stuff( b ); // a.b if it exists 0178 <endfold id='2'>}</endfold id='2'> while (itmakessense); 0179 <endfold id='2'>}</endfold id='2'> 0180 0181 switch (i) <beginfold id='2'>{</beginfold id='2'> 0182 case 0: 0183 f(); 0184 break; 0185 default: 0186 break; 0187 <endfold id='2'>}</endfold id='2'> 0188 0189 // Numerics 0190 var a = 0xA; 0191 var b = 0b1; 0192 var c = 0o7; 0193 var c = 07; 0194 var c = 08; 0195 var d = 1.1E+3; 0196 var e = 1.E+3; 0197 var f = .1E+3; 0198 var g = 1E+3; 0199 var h = 1.1; 0200 var i = 1.; 0201 var j = .1; 0202 var k = 1; 0203 // Bigint 0204 const binBig = 0b101n; 0205 const octBig = 0o567n; 0206 const hexBig = 0xC0Bn; 0207 const decBig = 123n; 0208 // Invalid numbers 0209 var l = 0xA1t; 0210 var m = 0b0123; 0211 var n = 0o29; 0212 var n = 000_7; 0213 // Number with separator 0214 let a = 0xA_b_1 0215 let a = 0xA_b_1n 0216 let a = 0xA_b_1_ 0217 let a = 0xA_b__1 0218 let b = 0o1_2_3 0219 let b = 0o1_2_3n 0220 let b = 0o1_2_3_ 0221 let b = 0o1_2__3 0222 let b = 0o1_2_38 0223 let b = 01_2_3 0224 let b = 01_2_3n 0225 let b = 01_2_3_ 0226 let b = 01_2__3 0227 let c = 0b0_1_1 0228 let c = 0b0_1_1n 0229 let c = 0b0_1_1_ 0230 let c = 0b0_1__1 0231 let d = 1_2_3 0232 let d = 1_2_3n 0233 let d = 1_2_3_ 0234 let d = 1_2__3 0235 let d = 01_2_8