Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
declare module "prism-react-renderer" {
import * as React from "react";
import type PrismJS from 'prismjs';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there additional work needed to ensure this type definition gets included in the npm package?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no additional work needed -- index.d.ts is already included in the tar


type Language =
| "markup"
Expand Down Expand Up @@ -45,8 +46,7 @@ declare module "prism-react-renderer" {
languages: LanguageDict;
tokenize: (
code: string,
grammar: PrismGrammar,
language: Language
grammar: PrismGrammar
) => PrismToken[] | string[];
highlight: (
code: string,
Expand Down Expand Up @@ -155,7 +155,7 @@ declare module "prism-react-renderer" {
};

interface HighlightProps {
Prism: PrismLib;
Prism: PrismLib | PrismJS;
theme?: PrismTheme;
language: Language;
code: string;
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"@rollup/plugin-commonjs": "^17.1.0",
"@rollup/plugin-node-resolve": "^11.2.0",
"@testing-library/react": "^11.2.5",
"@types/prismjs": "^1.26.0",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^26.6.3",
"babel-plugin-macros": "^3.0.1",
Expand Down
6 changes: 1 addition & 5 deletions src/components/Highlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,7 @@ class Highlight extends Component<Props, *> {
};

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

return tokens;
Expand Down
6 changes: 1 addition & 5 deletions src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@ export type Token = {

export type PrismLib = {
languages: LanguagesDict,
tokenize: (
code: string,
grammar: PrismGrammar,
language: Language
) => Array<PrismToken | string>,
tokenize: (code: string, grammar: PrismGrammar) => Array<PrismToken | string>,
highlight: (
code: string,
grammar: PrismGrammar,
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1316,6 +1316,11 @@
resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.2.1.tgz#374e31645d58cb18a07b3ecd8e9dede4deb2cccd"
integrity sha512-DxZZbyMAM9GWEzXL+BMZROWz9oo6A9EilwwOMET2UVu2uZTqMWS5S69KVtuVKaRjCUpcrOXRalet86/OpG4kqw==

"@types/prismjs@^1.26.0":
version "1.26.0"
resolved "https://registry.yarnpkg.com/@types/prismjs/-/prismjs-1.26.0.tgz#a1c3809b0ad61c62cac6d4e0c56d610c910b7654"
integrity sha512-ZTaqn/qSqUuAq1YwvOFQfVW1AR/oQJlLSZVustdjwI+GZ8kr0MSHBj0tsXPW1EqHubx50gtBEjbPGsdZwQwCjQ==

"@types/resolve@1.17.1":
version "1.17.1"
resolved "https://registry.yarnpkg.com/@types/resolve/-/resolve-1.17.1.tgz#3afd6ad8967c77e4376c598a82ddd58f46ec45d6"
Expand Down