Skip to content

Commit

Permalink
Fix Flow errors and revert upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
kitten committed Feb 20, 2021
1 parent 1b77bf4 commit f879697
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"babel-jest": "^26.6.3",
"babel-plugin-macros": "^3.0.1",
"codegen.macro": "^4.1.0",
"flow-bin": "^0.145.0",
"flow-bin": "0.123.0",
"globby": "^11.0.2",
"husky": "^4.2.5",
"jest": "^26.6.3",
Expand Down
15 changes: 10 additions & 5 deletions src/components/Highlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Highlight extends Component<Props, *> {
prevLanguage: Language | void;
themeDict: ThemeDict | void;

getThemeDict = (props: Props) => {
getThemeDict = (props: Props): ThemeDict | void => {
if (
this.themeDict !== undefined &&
props.theme === this.prevTheme &&
Expand Down Expand Up @@ -128,21 +128,26 @@ class Highlight extends Component<Props, *> {
code: string,
grammar: PrismGrammar,
language: Language
): Array<PrismToken> => {
): Array<PrismToken | string> => {
const env = {
code,
grammar,
language,
tokens: [],
};

Prism.hooks.run("before-tokenize", env);
env.tokens = Prism.tokenize(env.code, env.grammar, env.language);
const tokens = (env.tokens = Prism.tokenize(
env.code,
env.grammar,
env.language
));
Prism.hooks.run("after-tokenize", env);

return env.tokens;
return tokens;
};

render() {
render(): Node {
const { Prism, language, code, children } = this.props;

const themeDict = this.getThemeDict(this.props);
Expand Down
2 changes: 2 additions & 0 deletions src/vendor/prism/prism-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,9 @@ var Prism = (function () {
grammar: grammar,
language: language,
};
_.hooks.run("before-tokenize", env);
env.tokens = _.tokenize(env.code, env.grammar);
_.hooks.run("after-tokenize", env);
return Token.stringify(_.util.encode(env.tokens), env.language);
},

Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2465,10 +2465,10 @@ find-versions@^4.0.0:
dependencies:
semver-regex "^3.1.2"

flow-bin@^0.145.0:
version "0.145.0"
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.145.0.tgz#922f7c3568caaa5eb64621ec536deb56b24d1795"
integrity sha512-+9fi9BMxRBtSWC1x0hWggWTb8Vih+AC7wyvLAX5wR1m6u2lF2HLtixXqy2GX8bWgaynSEJR5lmPxYYC4wMI8cA==
flow-bin@0.123.0:
version "0.123.0"
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.123.0.tgz#7ba61a0b8775928cf4943ccf78eed2b1b05f7b3a"
integrity sha512-Ylcf8YDIM/KrqtxkPuq+f8O+6sdYA2Nuz5f+sWHlp539DatZz3YMcsO1EiXaf1C11HJgpT/3YGYe7xZ9/UZmvQ==

for-in@^1.0.2:
version "1.0.2"
Expand Down

0 comments on commit f879697

Please sign in to comment.