Warning, /frameworks/syntax-highlighting/autotests/input/test.jsx is written in an unsupported language. File is not indexed.
0001 // JavaScript React
0002
0003 /** @author Willy <willy@wmail.com>
0004 * @url https://reactjs.org/ **/
0005
0006 import React from 'react';
0007 import { PhotoStory, VideoStory } from './stories';
0008
0009 function Story(props) {
0010 const SpecificStory = components[props.storyType];
0011 return <SpecificStory story={ props.story } attr2="&ref;" attr3="Hello\n" />;
0012 }
0013
0014 function
0015 <Tag attr1={ <tag/> function <noTag/> return class var 0x123 { } &noRef; hello() React.Component() } attr2="&ref;">
0016 /* no comment*/ function <tag/> return class var 0x123 &ref; hello() React.Component()
0017 .<tag/> anyWord <tag/>
0018 { function <tag> return class var 0x123 hello() React.Component() }
0019 </Tag>
0020
0021 <tag1> </tag1>
0022 <tag1> </Tag$>
0023 <Tag$> </tag>
0024
0025 <tag/*comment*/attr1/*comment*/= /*comment*/"value"/*comment*/attr2 /*comment*/attr3='a' key/*comment*/key2 />
0026
0027 // Detect Valid tags
0028
0029 /* comment */ <tag></tag>
0030 { /* comment
0031 */ <Tag />
0032 word <noTag/> . <noTag/> } <noTag/>
0033 return /* comment
0034 multiline */ <tag/> /* comment */ <Tag/>
0035 && /*comment*/ <Tag/>
0036 & /*comment*/ <noTag/>
0037
0038 <tag/>
0039 { <hello>Hello</hello> }
0040 ?<Tag />;
0041 [ <tag /> ( <tag /> ]
0042 ,<Tag/> =<Tag/>
0043 &&<tag/> ||<tag/>
0044 return <tag/> ;
0045 default<tag/> ;
0046 <Tag> <tag> <tag$/> </tag> return </Tag>
0047
0048 anyWord<noTag>
0049 anyWord/*comment*/ <noTag/>
0050 .<noTag>
0051 &<notag> | <noTag/>
0052 % /* comment*/ <noTag/>
0053
0054 // Non-ASCII tag name & attribute
0055 <日本語></日本語>;
0056 <Component 本本:本-本 aa本:本 aa:aa />
0057
0058 <Namespace.DeepNamespace.Component />;
0059 <Component { ... x } y
0060 ={2 } z />;
0061
0062 let k1 = <div> <h2> Hello </h2> <h1> world </h1></div>;
0063 let k2 = <Button> <h2> Hello </h2> </Button>;
0064
0065 // Empty tags
0066 <></>; // no whitespace
0067 < ></ >; // lots of whitespace
0068 < /*starting wrap*/ ></ /*ending wrap*/>; // comments in the tags
0069 <>hi</>; // text inside
0070 <><span>hi</span><div>bye</div></>; // children
0071 <><span>1</span><><span>2.1</span><span>2.2</span></><span>3</span></>; // nested fragments
0072 <>#</>; // # would cause scanning error if not in jsxtext
0073
0074 // Tags after substitutions in templates
0075 `aaa${<tag></tag>//comment
0076 /*comment*/<A/>}`
0077
0078 // Don't highlight tags within variable declaration
0079 let myIdentity: <T>(arg: T) => T = identity;
0080 var myIdentity: <U>(arg: U) => U = identity;
0081 const myIdentity: {<T>(arg: T): T} = identity;
0082
0083 // Don't highlight tags within interfaces and classes
0084 interface GenericIdentityFn {
0085 <T>(arg: T): T;
0086 <noTag />
0087 }
0088 class Handler {
0089 info: <T>(arg: T): T <noTag />;
0090 <tag> </tag>
0091 }
0092
0093 // Check character after tag name, do not highlight invalid tags
0094 <noTag ?
0095 <noTag ,
0096 <noTag /* comment */ ?
0097 <noTag#
0098 <noTag/*comment*/#
0099
0100 // Tagged template literals
0101 tagFunc`
0102 Hello world!
0103 ${ <Tag />; 22 + "11" }`;
0104 obj.something.tagFunc`Setting ${setting} is ${value}!`;