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