1 | declare module "prism-react-renderer" {
|
2 | import * as React from "react";
|
3 |
|
4 | type Language =
|
5 | | "markup"
|
6 | | "bash"
|
7 | | "clike"
|
8 | | "c"
|
9 | | "cpp"
|
10 | | "css"
|
11 | | "javascript"
|
12 | | "jsx"
|
13 | | "coffeescript"
|
14 | | "actionscript"
|
15 | | "css-extr"
|
16 | | "diff"
|
17 | | "git"
|
18 | | "go"
|
19 | | "graphql"
|
20 | | "handlebars"
|
21 | | "json"
|
22 | | "less"
|
23 | | "makefile"
|
24 | | "markdown"
|
25 | | "objectivec"
|
26 | | "ocaml"
|
27 | | "python"
|
28 | | "reason"
|
29 | | "sass"
|
30 | | "scss"
|
31 | | "sql"
|
32 | | "stylus"
|
33 | | "tsx"
|
34 | | "typescript"
|
35 | | "wasm"
|
36 | | "yaml";
|
37 |
|
38 | type PrismGrammar = {
|
39 | [key: string]: any;
|
40 | };
|
41 |
|
42 | type LanguageDict = { [lang in Language]: PrismGrammar };
|
43 |
|
44 | type PrismLib = {
|
45 | languages: LanguageDict;
|
46 | tokenize: (
|
47 | code: string,
|
48 | grammar: PrismGrammar,
|
49 | language: Language
|
50 | ) => PrismToken[] | string[];
|
51 | highlight: (
|
52 | code: string,
|
53 | grammar: PrismGrammar,
|
54 | language: Language
|
55 | ) => string;
|
56 | };
|
57 |
|
58 | type PrismThemeEntry = {
|
59 | color?: string;
|
60 | backgroundColor?: string;
|
61 | fontStyle?: "normal" | "italic";
|
62 | fontWeight?:
|
63 | | "normal"
|
64 | | "bold"
|
65 | | "100"
|
66 | | "200"
|
67 | | "300"
|
68 | | "400"
|
69 | | "500"
|
70 | | "600"
|
71 | | "700"
|
72 | | "800"
|
73 | | "900";
|
74 | textDecorationLine?:
|
75 | | "none"
|
76 | | "underline"
|
77 | | "line-through"
|
78 | | "underline line-through";
|
79 | opacity?: number;
|
80 | [styleKey: string]: string | number | void;
|
81 | };
|
82 |
|
83 | type PrismTheme = {
|
84 | plain: PrismThemeEntry;
|
85 | styles: Array<{
|
86 | types: string[];
|
87 | style: PrismThemeEntry;
|
88 | languages?: Language[];
|
89 | }>;
|
90 | };
|
91 |
|
92 | type ThemeDict = {
|
93 | root: StyleObj;
|
94 | plain: StyleObj;
|
95 | [type: string]: StyleObj;
|
96 | };
|
97 |
|
98 | type Token = {
|
99 | types: string[];
|
100 | content: string;
|
101 | empty?: boolean;
|
102 | };
|
103 |
|
104 | type PrismToken = {
|
105 | type: string;
|
106 | content: Array<PrismToken | string> | string;
|
107 | };
|
108 |
|
109 | type StyleObj = {
|
110 | [key: string]: string | number | null;
|
111 | };
|
112 |
|
113 | type LineInputProps = {
|
114 | key?: React.Key;
|
115 | style?: StyleObj;
|
116 | className?: string;
|
117 | line: Token[];
|
118 | [otherProp: string]: any;
|
119 | };
|
120 |
|
121 | type LineOutputProps = {
|
122 | key?: React.Key;
|
123 | style?: StyleObj;
|
124 | className: string;
|
125 | [otherProps: string]: any;
|
126 | };
|
127 |
|
128 | type TokenInputProps = {
|
129 | key?: React.Key;
|
130 | style?: StyleObj;
|
131 | className?: string;
|
132 | token: Token;
|
133 | [otherProp: string]: any;
|
134 | };
|
135 |
|
136 | type TokenOutputProps = {
|
137 | key?: React.Key;
|
138 | style?: StyleObj;
|
139 | className: string;
|
140 | children: string;
|
141 | [otherProp: string]: any;
|
142 | };
|
143 |
|
144 | type RenderProps = {
|
145 | tokens: Token[][];
|
146 | className: string;
|
147 | style: StyleObj;
|
148 | getLineProps: (input: LineInputProps) => LineOutputProps;
|
149 | getTokenProps: (input: TokenInputProps) => TokenOutputProps;
|
150 | };
|
151 |
|
152 | type DefaultProps = {
|
153 | Prism: PrismLib;
|
154 | theme: PrismTheme;
|
155 | };
|
156 |
|
157 | interface HighlightProps {
|
158 | Prism: PrismLib;
|
159 | theme?: PrismTheme;
|
160 | language: Language;
|
161 | code: string;
|
162 | children: (props: RenderProps) => React.ReactNode;
|
163 | }
|
164 |
|
165 | export default class Highlight extends React.Component<HighlightProps> {
|
166 | themeDict: ThemeDict;
|
167 | getLineProps: (lineInputProps: LineInputProps) => LineOutputProps;
|
168 | getStyleForToken: (token: Token) => { [inlineStyle: string]: string };
|
169 | getTokenProps: (tokenInputPropsL: TokenInputProps) => TokenOutputProps;
|
170 | }
|
171 |
|
172 | export const defaultProps: DefaultProps;
|
173 |
|
174 | export const Prism: PrismLib;
|
175 |
|
176 | export { Language, DefaultProps, PrismTheme };
|
177 | }
|
178 |
|
179 | declare module "prism-react-renderer/themes/*" {
|
180 | import { PrismTheme } from "prism-react-renderer";
|
181 | const theme: PrismTheme;
|
182 | export default theme;
|
183 | }
|