-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add hook#run to vendored prism-core. This will allow for users to cus…
…tomize prism to run hooks without it breaking
- Loading branch information
1 parent
4a28c43
commit 5d0a7fc
Showing
2 changed files
with
552 additions
and
541 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,112 +1,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 | ||
}; | ||
|
||
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[] | ||
}> | ||
}; | ||
// @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[], | ||
}>, | ||
}; |
Oops, something went wrong.