-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added tsx support * fixed order in components.js and added tsx example file * escape less than and capitalize tsx
- Loading branch information
Showing
9 changed files
with
151 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
var typescript = Prism.util.clone(Prism.languages.typescript); | ||
Prism.languages.tsx = Prism.languages.extend('jsx', typescript); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<h1>React TSX</h1> | ||
<p>To use this language, use the class "language-tsx".</p> | ||
|
||
<h2>Full example</h2> | ||
<pre><code>import * as React from 'react'; | ||
|
||
interface IState { | ||
clicks: number; | ||
} | ||
|
||
export class Clicker extends React.Component<any, IState> { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.state = { | ||
clicks: 0, | ||
}; | ||
} | ||
|
||
public clickHandler = () => { | ||
this.setState({ clicks: this.state.clicks + 1 }); | ||
} | ||
|
||
public render() { | ||
return ( | ||
<div> | ||
<p>You have clicked the button {this.state.clicks} time(s).</p> | ||
<p> | ||
<button onClick={this.clickHandler}>click me</button> | ||
</p> | ||
</div> | ||
); | ||
} | ||
}</code></pre> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
var myDivElement = <div className="foo" />; | ||
var myElement = <MyComponent someProperty={true} />; | ||
<div {...foo}> | ||
class Test extends Component { | ||
render() { | ||
return <p onClick={this.clickHandler}>Hello world.</p>; | ||
} | ||
} | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["keyword", "var"], | ||
" myDivElement ", | ||
["operator", "="], | ||
["tag", [ | ||
["tag", [ | ||
["punctuation", "<"], | ||
"div" | ||
]], | ||
["attr-name", ["className"]], | ||
["attr-value", [ | ||
["punctuation", "="], | ||
["punctuation", "\""], | ||
"foo", | ||
["punctuation", "\""] | ||
]], | ||
["punctuation", "/>"] | ||
]], | ||
["punctuation", ";"], | ||
|
||
["keyword", "var"], | ||
" myElement ", | ||
["operator", "="], | ||
["tag", [ | ||
["tag", [ | ||
["punctuation", "<"], | ||
"MyComponent" | ||
]], | ||
["attr-name", ["someProperty"]], | ||
["script", [ | ||
["punctuation", "="], | ||
["punctuation", "{"], | ||
["boolean", "true"], | ||
["punctuation", "}"] | ||
]], | ||
["punctuation", "/>"] | ||
]], | ||
["punctuation", ";"], | ||
["tag", [ | ||
["tag", [ | ||
["punctuation", "<"], | ||
"div" | ||
]], | ||
["spread", [ | ||
["punctuation", "{"], | ||
["punctuation", "..."], | ||
["attr-value", "foo"], | ||
["punctuation", "}"] | ||
]], | ||
["punctuation", ">"] | ||
]], | ||
|
||
["keyword", "class"], | ||
["class-name", ["Test"]], | ||
["keyword", "extends"], | ||
["class-name", ["Component"]], | ||
["punctuation", "{"], | ||
["function", "render"], | ||
["punctuation", "("], | ||
["punctuation", ")"], | ||
["punctuation", "{"], | ||
["keyword","return"], | ||
["tag", [ | ||
["tag", [ | ||
["punctuation", "<"], | ||
"p" | ||
]], | ||
["attr-name", ["onClick"]], | ||
["script", [ | ||
["punctuation", "="], | ||
["punctuation", "{"], | ||
["keyword", "this"], | ||
["punctuation", "."], | ||
"clickHandler", | ||
["punctuation", "}"] | ||
]], | ||
["punctuation", ">"] | ||
]], | ||
"Hello world", | ||
["punctuation", "."], | ||
["tag", [ | ||
["tag", [ | ||
["punctuation", "</"], | ||
"p" | ||
]], | ||
["punctuation", ">"] | ||
]], | ||
["punctuation", ";"], | ||
["punctuation", "}"], | ||
["punctuation","}"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for TSX tags. |