forked from FormidableLabs/prism-react-renderer
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtypes.js
executable file
·122 lines (107 loc) · 2.22 KB
/
types.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
// @flow
import type { Key } from "react";
import includedLangs from "./vendor/prism/includeLangs";
export type Language = $Keys<typeof includedLangs>;
export type PrismGrammar = {
[key: string]: mixed,
};
type LanguagesDict = {
[lang: Language]: PrismGrammar,
};
export type PrismToken = {
type: string | string[],
alias: string | string[],
content: Array<PrismToken | string> | string,
};
export type Token = {
types: string[],
content: string,
empty?: boolean,
};
export type PrismLib = {
languages: LanguagesDict,
tokenize: (
code: string,
grammar: PrismGrammar,
language: Language
) => Array<PrismToken | string>,
highlight: (
code: string,
grammar: PrismGrammar,
language: Language
) => string,
hooks: {
run: (
name: string,
env: { code: string, grammar: PrismGrammar, language: Language }
) => void,
},
};
export type StyleObj = {
[key: string]: string | number | null,
};
export type LineInputProps = {
key?: Key,
style?: StyleObj,
className?: string,
line: Token[],
[key: string]: mixed,
};
export type LineOutputProps = {
key?: Key,
style?: StyleObj,
className: string,
[key: string]: mixed,
};
export type TokenInputProps = {
key?: Key,
style?: StyleObj,
className?: string,
token: Token,
[key: string]: mixed,
};
export type TokenOutputProps = {
key?: Key,
style?: StyleObj,
className: string,
children: string,
[key: string]: mixed,
};
export type RenderProps = {
tokens: Token[][],
className: string,
getLineProps: (input: LineInputProps) => LineOutputProps,
getTokenProps: (input: TokenInputProps) => TokenOutputProps,
};
export type PrismThemeEntry = {
color?: string,
backgroundColor?: string,
fontStyle?: "normal" | "italic",
fontWeight?:
| "normal"
| "bold"
| "100"
| "200"
| "300"
| "400"
| "500"
| "600"
| "700"
| "800"
| "900",
textDecorationLine?:
| "none"
| "underline"
| "line-through"
| "underline line-through",
opacity?: number,
[styleKey: string]: string | number | void,
};
export type PrismTheme = {
plain: PrismThemeEntry,
styles: Array<{
types: string[],
style: PrismThemeEntry,
languages?: Language[],
}>,
};