diff --git a/src/auto-start.ts b/src/auto-start.ts
index bbbaecf7ad..095b0edd73 100644
--- a/src/auto-start.ts
+++ b/src/auto-start.ts
@@ -4,16 +4,15 @@ import autoloader from './plugins/autoloader/prism-autoloader';
Prism.components.add(autoloader);
export const PrismConfig = {
- // TODO: Update docs
/**
- * By default, Prism will attempt to highlight all code elements (by calling {@link Prism#highlightAll}) on the
- * current page after the page finished loading. This might be a problem if e.g. you wanted to asynchronously load
+ * By default, Prism will attempt to highlight all code elements (by calling {@link Prism.highlightAll}) on the
+ * current page after the page finishes loading. This might be a problem if e.g. you wanted to asynchronously load
* additional languages or plugins yourself.
*
* By setting this value to `true`, Prism will not automatically highlight all code elements on the page.
*
- * You obviously have to change this value before the automatic highlighting started. To do this, you can add an
- * empty Prism object into the global scope before loading the Prism script like this:
+ * You have to change this value before the automatic highlighting starts. To do this, you can add an
+ * empty Prism object into the global scope before the Prism script loads like this:
*
* ```js
* window.Prism = window.Prism || {};
@@ -21,6 +20,11 @@ export const PrismConfig = {
* // add a new
+ * ```
+ *
* @default false
* @public
*/
diff --git a/src/core/prism.ts b/src/core/prism.ts
index ed1324f8a9..f4d9cfa8c5 100644
--- a/src/core/prism.ts
+++ b/src/core/prism.ts
@@ -25,13 +25,13 @@ export class Prism {
/**
* This is the most high-level function in Prism’s API.
- * It queries all the elements that have a `.language-xxxx` class and then calls {@link Prism#highlightElement} on
+ * It queries all the elements that have a `.language-xxxx` class and then calls {@link Prism.highlightElement} on
* each one of them.
*
* The following hooks will be run:
* 1. `before-highlightall`
* 2. `before-all-elements-highlight`
- * 3. All hooks of {@link Prism#highlightElement} for each element.
+ * 3. All hooks of {@link Prism.highlightElement} for each element.
*/
highlightAll (options: HighlightAllOptions = {}) {
const { root, async, callback } = options;
@@ -63,7 +63,7 @@ export class Prism {
* The following hooks will be run:
* 1. `before-sanity-check`
* 2. `before-highlight`
- * 3. All hooks of {@link Prism#highlight}. These hooks will be run by an asynchronous worker if `async` is `true`.
+ * 3. All hooks of {@link Prism.highlight}. These hooks will be run by an asynchronous worker if `async` is `true`.
* 4. `before-insert`
* 5. `after-highlight`
* 6. `complete`
@@ -162,7 +162,13 @@ export class Prism {
* Usually a language definition like `Prism.languages.markup`.
* @returns The highlighted HTML.
* @example
- * Prism.highlight('var foo = true;', 'javascript');
+ * import { Prism } from './src/core/prism';
+ * import javascript from './src/languages/prism-javascript';
+ * const prism = new Prism();
+ * prism.components.add(javascript);
+ * prism.highlight('var foo = true;', 'javascript')
+ * // Returns:
+ * `var foo = true;`
*/
highlight (text: string, language: string, options?: HighlightOptions): string {
const languageId = this.components.resolveAlias(language);
@@ -199,14 +205,22 @@ export class Prism {
* Usually a language definition like `Prism.languages.markup`.
* @returns An array of strings and tokens, a token stream.
* @example
- * let code = `var foo = 0;`;
- * let tokens = Prism.tokenize(code, Prism.getLanguage('javascript'));
- * tokens.forEach(token => {
- * if (token instanceof Token && token.type === 'number') {
- * console.log(`Found numeric literal: ${token.content}`);
- * }
+ * import { Token } from './src/core';
+ * import { Prism } from './src/core/prism';
+ * import javascript from './src/languages/prism-javascript';
+ *
+ * const prism = new Prism();
+ * prism.components.add(javascript);
+ *
+ * const tokens = prism.tokenize(`var foo = 0;`, prism.components.getLanguage('javascript')!);
+ * tokens.forEach((token: Token | string) => {
+ * if (token instanceof Token && token.type === 'number') {
+ * console.log(`Found numeric literal: ${token.content}`);
+ * }
* });
+ * // Logs: Found numeric literal: 0
*/
+
tokenize (text: string, grammar: Grammar): TokenStream {
const customTokenize = grammar[tokenize];
if (customTokenize) {