>3>>; // nested fragments
+<>#>; // # would cause scanning error if not in jsxtext
diff --git a/autotests/html/test.jsx.html b/autotests/html/test.jsx.html
index b19eabe..c248848 100644
--- a/autotests/html/test.jsx.html
+++ b/autotests/html/test.jsx.html
@@ -1,59 +1,84 @@
test.jsx
// JavaScript React
/** @author Willy <willy@wmail.com>
* @url https://reactjs.org/ **/
import React from 'react';
import { PhotoStory, VideoStory } from './stories';
function Story(props) {
const SpecificStory = components[props.storyType];
return <SpecificStory story={ props.story } attr2="&ref;" attr3="Hello\n" />;
}
function
<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() }
</Tag>
<tag1> </tag1>
<tag1> </Tag$>
<Tag$> </tag>
<tag/*comment*/attr1/*comment*/= /*comment*/"value"/*comment*/attr2 /*comment*/attr3='a' key/*comment*/key2 />
// Detect Valid tags
/* comment */ <tag></tag>
{ /* comment
*/ <Tag />
word <noTag/> . <noTag/> } <noTag/>
return /* comment
multiline */ <tag/> /* comment */ <Tag/>
&& /*comment*/ <Tag/>
& /*comment*/ <noTag/>
<tag/>
{ <hello>Hello</hello> }
?<Tag />;
[ <tag /> ( <tag />
,<Tag/> =<Tag/>
&&<tag/> ||<tag/>
return <tag/> ;
default<tag/> ;
<Tag> <tag> <tag$/> </tag> return </Tag>
anyWord<noTag>
anyWord/*comment*/ <noTag/>
.<noTag>
&<notag> | <noTag/>
% /* comment*/ <noTag/>
+
+<C<number>/>
+<C<number>> </C>
+<C
+<error />
+
+// Non-ASCII tag name & attribute
+<日本語></日本語>;
+<Component 本本:本-本 aa本:本 aa:aa />
+
+<Namespace.DeepNamespace.Component />;
+<Component { ... x } y
+={2 } z />;
+
+let k1 = <div> <h2> Hello </h2> <h1> world </h1></div>;
+let k2 = <Button> <h2> Hello </h2> </Button>;
+
+// Empty tags
+<></>; // no whitespace
+< ></ >; // lots of whitespace
+< /*starting wrap*/ ></ /*ending wrap*/>; // comments in the tags
+<>hi</>; // text inside
+<><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
diff --git a/autotests/html/test.ts.html b/autotests/html/test.ts.html
index fb89fe3..71c5246 100644
--- a/autotests/html/test.ts.html
+++ b/autotests/html/test.ts.html
@@ -1,57 +1,118 @@
test.ts
/// <reference types="node" />
// TypeScript Test
class Student {
fullName: string;
constructor(public firstName: string, public middleInitial: string, public lastName: string) {
this.fullName = firstName + " " + middleInitial + " " + lastName;
}
}
interface Person {
firstName: string;
lastName: string;
}
function greeter(person : Person) {
return "Hello, " + person.firstName + " " + person.lastName;
}
let user = new Student("Jane", "M.", "User");
document.body.innerHTML = greeter(user);
JSON.stringify()
console.log("Hello world");
import http = require("http");
import path = require("path");
import URL = url.URL;
import { Readable, Writable } from "stream";
import { isBuffer, isString, isObject } from "util";
const port = 8__88___8;
const baseUrl = new URL(`http://localhost:${port}/`);
const rootDir = path.dirname(__dirname);
const defaultBrowser = os.platform() === "win32" ? "edge" : "chrome";
let browser: "edge" | "chrome" | "none" = defaultBrowser;
-let grep: string | undefined;
+let grep: string | undefined;
interface FileBasedTestConfiguration {
[setting: string]: string;
}
function swapCase(s: string): string {
return s.replace(/\w/g, (ch) => {
const up = ch.toUpperCase();
return ch === up ? ch.toLowerCase() : up;
});
}
+
+for (var i in pieces) {
+ switch (true) {
+ case /^\"?Accession\"?/.test(pieces[i]):
+ numeration[0] = i;
+ break;
+ }
+}
+
+// Numerics
+var a = 0xA;
+var b = 0b1;
+var c = 0o7;
+var d = 1.1E+3;
+var e = 1.E+3;
+var f = .1E+3;
+var g = 1E+3;
+var h = 1.1;
+var i = 1.;
+var j = .1;
+var k = 1;
+var l = 1__.e+3_22 | .2____e2 | 0o1_23 | 11__. ;
+
+// Types
+let a: null = null;
+let b: number = 123;
+let c: number = 123.456;
+let d: string = `Geeks`;
+let e: undefined = undefined;
+let f: boolean = true;
+let g: number = 0b111001; // Binary
+let h: number = 0o436; // Octal
+let i: number = 0xadf0d; // Hexa-Decimal
+
+const query = query<[number], number>(`
+ SELECT *
+ FROM statistics
+ WHERE unit_id = $1`)
+
+function runQuery() {
+ const query = createQuery<[number[]], Table<Columns>>(`
+ some SQL here
+ `)
+ return database.execute(query)
+}
+
+aa: <sdf/> string ?<ssd/> string
+ string // Don't highlight
+aa: string assa |
+ string
+ string ;
+ string
+
+aa: { string
+ string } // Don't highlight
+
+aa: [ string
+ string ]
+aa: ( string
+ string ) // Don't highlight
+aa: string <string>
diff --git a/autotests/html/test.tsx.html b/autotests/html/test.tsx.html
index 847b6d0..bba3f83 100644
--- a/autotests/html/test.tsx.html
+++ b/autotests/html/test.tsx.html
@@ -1,63 +1,118 @@
test.tsx
// TypeScript React
/** @author Willy <willy@wmail.com>
* @url https://reactjs.org/ **/
import React from 'react';
import { PhotoStory, VideoStory } from './stories';
function Story(props) {
const SpecificStory = components[props.storyType];
return <SpecificStory story={ props.story } attr2="&ref;" attr3="Hello\n" />;
}
function
<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() }
</Tag>
<tag1> </tag1>
<tag1> </Tag$>
<Tag$> </tag>
<tag/*comment*/attr1/*comment*/= /*comment*/"value"/*comment*/attr2 /*comment*/attr3='a' key/*comment*/key2 />
// Detect Valid tags
/* comment */ <tag></tag>
{ /* comment
*/ <Tag />
word <noTag/> . <noTag/> } <noTag/>
return /* comment
multiline */ <tag/> /* comment */ <Tag/>
&& /*comment*/ <Tag/>
& /*comment*/ <noTag/>
<tag/>
{ <hello>Hello</hello> }
?<Tag />;
[ <tag /> ( <tag />
,<Tag/> =<Tag/>
&&<tag/> ||<tag/>
return <tag/> ;
default<tag/> ;
<Tag> <tag> <tag$/> </tag> return </Tag>
anyWord<noTag>
anyWord/*comment*/ <noTag/>
.<noTag>
&<notag> | <noTag/>
% /* comment*/ <noTag/>
+// TODO: Fix this (comment before the tag name):
+var x = </**/div></div>;
+
+// Tag after ":"
annotation: <tag/>
annotation: text [ <tag/> ]
console.log("hello")
+
+// Type assertion in tag
+<C<number>/>
+<C<number>> </C>
+<C
+<error />
+
+// Non-ASCII tag name & attribute
+<日本語></日本語>;
+<Component 本本:本-本 aa本:本 aa:aa />
+<aaaa:ñ />
+
+<Namespace.DeepNamespace.Component />;
+<Component { ... x } y
+={2 } z />;
+
+let k1 =
+ <Comp a={10} b="hi" {...o} >
+ hi hi hi!
+ </Comp>;
+
+let k2 =
+ <Comp a={10} b="hi">
+ <div> My Div </div>
+ {(name: string) => <div> My name {name} </div>}
+ </Comp>;
+
+let k3 = <GenericComponent initialValues={{ x: "y" }} nextValues={a => ({ x: a.x })} />; // No Error
+
+// OK
+let k1 = <Comp a={10} b="hi"><></><Button /><AnotherButton /></Comp>;
+let k2 = <Comp a={10} b="hi"><><Button /></><AnotherButton /></Comp>;
+let k3 = <Comp a={10} b="hi"><><Button /><AnotherButton /></></Comp>;
+let k4 = <SingleChildComp a={10} b="hi"><><Button /><AnotherButton /></></SingleChildComp>;
+// OK
+let k1 = <div> <h2> Hello </h2> <h1> world </h1></div>;
+let k2 = <div> <h2> Hello </h2> {(user: any) => <h2>{user.name}</h2>}</div>;
+let k3 = <div> {1} {"That is a number"} </div>;
+let k4 = <Button> <h2> Hello </h2> </Button>;
+
+// Empty tags
+hello<>
+hello<string>
+
+<></>; // no whitespace
+< ></ >; // lots of whitespace
+< /*starting wrap*/ ></ /*ending wrap*/>; // comments in the tags
+<>hi</>; // text inside
+<><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
diff --git a/autotests/input/test.jsx b/autotests/input/test.jsx
index 483e116..f6fa5f7 100644
--- a/autotests/input/test.jsx
+++ b/autotests/input/test.jsx
@@ -1,52 +1,77 @@
// JavaScript React
/** @author Willy
* @url https://reactjs.org/ **/
import React from 'react';
import { PhotoStory, VideoStory } from './stories';
function Story(props) {
const SpecificStory = components[props.storyType];
return ;
}
function
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() }