diff --git a/autotests/folding/highlight.js.fold b/autotests/folding/highlight.js.fold
--- a/autotests/folding/highlight.js.fold
+++ b/autotests/folding/highlight.js.fold
@@ -77,11 +77,11 @@
something.method =
- function ( a, b, c ) { /* ... */ }
+ function ( a, b, c ) { /* ... */ }
// ^ fallthrough ?!
something.other =
-function ( d, e, f ) { /* ... */ }
+function ( d, e, f ) { /* ... */ }
// fallthrough expected at col 0 ("function" should be bold)
var ary = new Array(5);
@@ -109,31 +109,31 @@
return;
-try { bla() } catch (e) { alert("ERROR! : " + e) }
+try { bla() } catch (e) { alert("ERROR! : " + e) }
for (int i=0; i < j; i++)
document.write("i is" + i + "
");
while (something)
-{
+{
block();
picky:
if (!1)
break;
else
continue;
-}
+}
-with (a) {
- do {
+with (a) {
+ do {
stuff( b ); // a.b if it exists
- } while (itmakessense);
-}
+ } while (itmakessense);
+}
-switch (i) {
+switch (i) {
case 0:
f();
break;
default:
break;
-}
+}
diff --git a/autotests/folding/highlight.php.fold b/autotests/folding/highlight.php.fold
--- a/autotests/folding/highlight.php.fold
+++ b/autotests/folding/highlight.php.fold
@@ -13,6 +13,49 @@
print "
test"; ?>
+
+
+ >
+
+
+ >
+
+ >
+
+ >
+
+ >
+
/* comment */
function fun()
-{
- var boo = { 'key': [ 1, 2.0, 3.0e1, 004, 0x5 ] };
-}
+{
+ var boo = { 'key': [ 1, 2.0, 3.0e1, 004, 0x5 ] };
+}
class MyClass; // reserved keywords
diff --git a/autotests/folding/test.jsx.fold b/autotests/folding/test.jsx.fold
--- a/autotests/folding/test.jsx.fold
+++ b/autotests/folding/test.jsx.fold
@@ -12,7 +12,7 @@
}
function
- attr1={ /> function return class var 0x123 { } &noRef; hello() React.Component() } attr2="&ref;">
+ attr1={ /> function return class var 0x123 { } &noRef; hello() React.Component() } attr2="&ref;">
/* no comment*/ function /> return class var 0x123 &ref; hello() React.Component()
./> anyWord />
{ function return class var 0x123 hello() React.Component() }
@@ -27,16 +27,16 @@
// Detect Valid tags
/* comment */ >>
-{ /* comment
+{ /* comment
*/ />
word . }
return /* comment
multiline */ /> /* comment */ />
&& /*comment*/ />
& /*comment*/
/>
-{ >Hello> }
+{ >Hello> }
? />;
[ /> ( />
,/> =/>
@@ -75,3 +75,22 @@
<>>hi>>bye
>>; // children
<>>1><>>2.1>>2.2>>>3>>; // nested fragments
<>#>; // # would cause scanning error if not in jsxtext
+
+// Tags after substitutions in templates
+`aaa${>>//comment
+ /*comment*//>}`
+
+// Don't highlight tags within variable declaration
+let myIdentity: (arg: T) => T = identity;
+var myIdentity: (arg: U) => U = identity;
+const myIdentity: {<T>(arg: T): T} = identity;
+
+// Don't highlight tags within interfaces and classes
+interface GenericIdentityFn {
+ (arg: T): T;
+
+}
+class Handler {
+ info: (arg: T): T ;
+ > >
+}
diff --git a/autotests/folding/test.ts.fold b/autotests/folding/test.ts.fold
--- a/autotests/folding/test.ts.fold
+++ b/autotests/folding/test.ts.fold
@@ -57,6 +57,48 @@
}
}
+const enum ResponseCode {
+ Success = 200,
+ BadRequest = 400
+}
+
+// Substitutions
+export function isInOpenInterval(start: number, end: number) {
+ return tersible(a => a > start && a < end, () => `(${start}...${end})`)
+}
+const bar = `${x} ${y}`;
+
+// readonly
+function f1(mt: [number, number], rt: readonly [number, number]) {
+}
+
+function f2(ma: string[], ra: readonly string[], mt: [string, string], rt: readonly [string, string]) {
+}
+
+type ReadWrite = { -readonly [P in keyof T] : T[P] };
+
+// const assertion
+let obj = { x: 10, y: [20, 30], z: { a: { b: 42 } } } as const;
+let r2 = { x: 20, y: 10 } as const;
+let r2 = {...p} as const;
+let p1 = { x: 10, y: 20 as const };
+let p2 = { 10 as const, 'foo' as const };
+
+// Definite assignment operator
+class Cl {
+ one?: string;
+ two!: string;
+}
+let x! = 1;
+
+// Function with multiple arguments
+const children = [].map>>(element => {
+ if (!this.identityProvider) {
+ return element;
+ }
+ return element;
+});
+
// Numerics
var a = 0xA;
var b = 0b1;
@@ -71,6 +113,12 @@
var k = 1;
var l = 1__.e+3_22 | .2____e2 | 0o1_23 | 11__. ;
+// Bigint
+const binBig = 0b101n;
+const octBig = 0o567n;
+const hexBig = 0xC0Bn;
+const decBig = 123n;
+
// Types
let a: null = null;
let b: number = 123;
@@ -109,3 +157,25 @@
aa: ( string
string ) // Don't highlight
aa: string
+interface a {
+ aa: /* comment
+ */ string,
+ bb: /* comment */
+ number,
+ cc: // comment
+ void,
+ dd:
+ any,
+}
+
+null, <{[key]: () => any}> null
+null, <{[key]: () =>{a: number}}> null
+
+// Correctly highlighting regular expressions
+dt = ((dt[0] * 1e9 + dt[1]) / 1e6).toFixed(3).replace(/\.?0+$/, '') + 'ms';
+(a[0] / 2) / (2)
+
+// Type guards
+function isNumber(x: any): x is number {
+ return typeof x === "number";
+}
diff --git a/autotests/folding/test.tsx.fold b/autotests/folding/test.tsx.fold
--- a/autotests/folding/test.tsx.fold
+++ b/autotests/folding/test.tsx.fold
@@ -12,7 +12,7 @@
}
function
- attr1={ /> function return class var 0x123 { } &noRef; hello() React.Component() } attr2="&ref;">
+ attr1={ /> function return class var 0x123 { } &noRef; hello() React.Component() } attr2="&ref;">
/* no comment*/ function /> return class var 0x123 &ref; hello() React.Component()
./> anyWord />
{ function return class var 0x123 hello() React.Component() }
@@ -52,7 +52,7 @@
% /* comment*/
// TODO: Fix this (comment before the tag name):
-var x = **/div>;
+var x = </**/div>;
// Tag after ":"
annotation: />
@@ -109,3 +109,28 @@
<>>hi>>bye
>>; // children
<>>1><>>2.1>>2.2>>>3>>; // nested fragments
<>#>; // # would cause scanning error if not in jsxtext
+
+// Tags after substitutions in templates
+`aaa${>>//comment
+ /*comment*//>}`
+
+// Don't highlight tags within type declaration
+type T12 = ReturnType<(() => T)>;
+type T13 = ReturnType<([]>() => T)>;
+type T14 = ReturnType;
+type T15 = ReturnType<(s: string) => void>;
+
+// Don't highlight tags within variable declaration
+let myIdentity: (arg: T) => T = />;
+var myIdentity: (arg: U) => U = identity;
+const myIdentity: {(arg: T): T} = identity;
+
+// Don't highlight tags within interfaces and classes
+interface GenericIdentityFn {
+ (arg: T): T;
+
+}
+class Handler {
+ info: (arg: T): T ;
+ > >
+}
diff --git a/autotests/html/highlight.php.html b/autotests/html/highlight.php.html
--- a/autotests/html/highlight.php.html
+++ b/autotests/html/highlight.php.html
@@ -19,6 +19,49 @@
<html>
<? print "<title>test</title>"; ?>
+
+ <!-- CSS -->
+ <style>
+ .inputText {
+ width: <?php echo $width; ?>px;
+ text-indent: 10px;
+ }
+ </style>
+
+ <!-- JavaScript -->
+ <script>
+ var some_js_var = <?php echo $somevar; ?> ;
+ <?php echo 'alert("Hello there.");'; ?>
+ </script>
+ <!-- JavaScript React -->
+ <script type="text/babel">
+ <Hello> <?php echo("Hello, hello!"); ?> </Hello> <?php /* aaa */ ?> <div></div>
+ function a(i) {
+ <?php echo "var j = 1;"; ?>
+ return <p>{ i + j }</p>;
+ }
+ </script>
+ <!-- TypeScript -->
+ <script type="text/typescript">
+ <?php $timestamp = time(); ?>
+ class DateTime {
+ info: string;
+ constructor() { this.info = <?php echo(date("F d, Y h:i:s", $timestamp)); ?>; }
+ get() { return this.info; }
+ }
+ </script>
+ <!-- MustacheJS -->
+ <script type="x-tmpl-mustache">
+ {{! <?php print "comment"; ?> }}
+ {{#movie}}
+ <div>
+ <h1>{{title}}</h1>
+ <img src="{{poster}}" alt="{{title}}"/>
+ <?php echo $movierating; ?> - {{ratings.critics_rating}}
+ </div>
+ {{/movie}}
+ </script>
+
</html>
<?php
diff --git a/autotests/html/test.jsx.html b/autotests/html/test.jsx.html
--- a/autotests/html/test.jsx.html
+++ b/autotests/html/test.jsx.html
@@ -18,7 +18,7 @@
}
function
-<Tag attr1={ <tag/> function <noTag/> return class var 0x123 { } &noRef; hello() React.Component() } attr2="&ref;">
+<Tag attr1={ <tag/> function <noTag/> return class var 0x123 { } &noRef; hello() React.Component() } attr2="&ref;">
/* no comment*/ function <tag/> return class var 0x123 &ref; hello() React.Component()
.<tag/> anyWord <tag/>
{ function <tag> return class var 0x123 hello() React.Component() }
@@ -81,4 +81,23 @@
<><span>hi</span><div>bye</div></>; // children
<><span>1</span><><span>2.1</span><span>2.2</span></><span>3</span></>; // nested fragments
<>#</>; // # would cause scanning error if not in jsxtext
+
+// Tags after substitutions in templates
+`aaa${<tag></tag>//comment
+ /*comment*/<A/>}`
+
+// Don't highlight tags within variable declaration
+let myIdentity: <T>(arg: T) => T = identity;
+var myIdentity: <U>(arg: U) => U = identity;
+const myIdentity: {<T>(arg: T): T} = identity;
+
+// Don't highlight tags within interfaces and classes
+interface GenericIdentityFn {
+ <T>(arg: T): T;
+ <noTag />
+}
+class Handler {
+ info: <T>(arg: T): T <noTag />;
+ <tag> </tag>
+}