-
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.
Fix #1216
- Loading branch information
Showing
10 changed files
with
165 additions
and
2 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,34 @@ | ||
(function (Prism) { | ||
Prism.languages.flow = Prism.languages.extend('javascript', {}); | ||
|
||
Prism.languages.insertBefore('flow', 'keyword', { | ||
'type': [ | ||
{ | ||
pattern: /\b(?:[Nn]umber|[Ss]tring|[Bb]oolean|Function|any|mixed|null|void)\b/, | ||
alias: 'tag' | ||
} | ||
] | ||
}); | ||
Prism.languages.flow['function-variable'].pattern = /[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*(?=\s*=\s*(?:function\b|(?:\([^()]*\)(?:\s*:\s*\w+)?|[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*)\s*=>))/i; | ||
|
||
Prism.languages.insertBefore('flow', 'operator', { | ||
'flow-punctuation': { | ||
pattern: /\{\||\|\}/, | ||
alias: 'punctuation' | ||
} | ||
}); | ||
|
||
if (Prism.util.type(Prism.languages.flow.keyword) !== 'Array') { | ||
Prism.languages.flow.keyword = [Prism.languages.flow.keyword]; | ||
} | ||
Prism.languages.flow.keyword.unshift( | ||
{ | ||
pattern: /(^|[^$]\b)(?:type|opaque|declare|Class)\b(?!\$)/, | ||
lookbehind: true | ||
}, | ||
{ | ||
pattern: /(^|[^$]\B)\$(?:await|Diff|Exact|Keys|ObjMap|PropertyType|Shape|Record|Supertype|Subtype|Enum)\b(?!\$)/, | ||
lookbehind: true | ||
} | ||
); | ||
}(Prism)); |
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,21 @@ | ||
<h1>Flow</h1> | ||
<p>To use this language, use the class "language-flow".</p> | ||
|
||
<h2>Primitive types</h2> | ||
<pre><code>function method(x: number, y: string, z: boolean) {} | ||
function stringifyBasicValue(value: string | number) {} | ||
function add(one: any, two: any): number { | ||
return one + two; | ||
} | ||
|
||
const bar: number = 2; | ||
var barVar: number = 2; | ||
let barLet: number = 2; | ||
let isOneOf: number | boolean | string = foo;</code></pre> | ||
|
||
<h2>Keywords</h2> | ||
<pre><code>type UnionAlias = 1 | 2 | 3; | ||
opaque type ID = string; | ||
declare opaque type PositiveNumber: number; | ||
type Country = $Keys<typeof countries>; | ||
type RequiredProps = $Diff<Props, DefaultProps>;</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{| foo : string |} | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["flow-punctuation", "{|"], " foo ", ["punctuation", ":"], | ||
["type", "string"], ["flow-punctuation", "|}"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for Flow specific punctuation. |
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,20 @@ | ||
foo = (a: number) : number => {} | ||
bar = () : string => {} | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["function-variable", "foo"], ["operator", "="], | ||
["punctuation", "("], "a", ["punctuation", ":"], | ||
["type", "number"], ["punctuation", ")"], | ||
["punctuation", ":"], ["type", "number"], | ||
["operator", "=>"], ["punctuation", "{"], ["punctuation", "}"], | ||
["function-variable", "bar"], ["operator", "="], | ||
["punctuation", "("], ["punctuation", ")"], | ||
["punctuation", ":"], ["type", "string"], | ||
["operator", "=>"], ["punctuation", "{"], ["punctuation", "}"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for function variables containing types. |
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,39 @@ | ||
type | ||
opaque | ||
declare | ||
Class | ||
$await | ||
$Diff | ||
$Exact | ||
$Keys | ||
$ObjMap | ||
$PropertyType | ||
$Shape | ||
$Record | ||
$Supertype | ||
$Subtype | ||
$Enum | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["keyword", "type"], | ||
["keyword", "opaque"], | ||
["keyword", "declare"], | ||
["keyword", "Class"], | ||
["keyword", "$await"], | ||
["keyword", "$Diff"], | ||
["keyword", "$Exact"], | ||
["keyword", "$Keys"], | ||
["keyword", "$ObjMap"], | ||
["keyword", "$PropertyType"], | ||
["keyword", "$Shape"], | ||
["keyword", "$Record"], | ||
["keyword", "$Supertype"], | ||
["keyword", "$Subtype"], | ||
["keyword", "$Enum"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for keywords. |
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,31 @@ | ||
Number | ||
number | ||
String | ||
string | ||
Boolean | ||
boolean | ||
Function | ||
any | ||
mixed | ||
null | ||
void | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["type", "Number"], | ||
["type", "number"], | ||
["type", "String"], | ||
["type", "string"], | ||
["type", "Boolean"], | ||
["type", "boolean"], | ||
["type", "Function"], | ||
["type", "any"], | ||
["type", "mixed"], | ||
["type", "null"], | ||
["type", "void"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for types. |