# hooks - Documentation

# hooks

## Prism. hooks

Source:
  - prism-core.js, line 717

### Methods

#### (static) add(name, callback)

Source:
  - prism-core.js, line 732

Adds the given callback to the list of callbacks for the given hook.

The callback will be invoked when the hook it is registered for is run. Hooks are usually directly run by a highlight function but you can also run hooks yourself.

One callback function can be registered to multiple hooks and the same hook multiple times.

##### Parameters:

Name | Type | Description
--- | --- | ---
`name` | string | The name of the hook.
`callback` | HookCallback | The callback function which is given environment variables.

#### (static) run(name, env)

Source:
  - prism-core.js, line 749

Runs a hook invoking all registered callbacks with the given environment variables.

Callbacks will be invoked synchronously and in the order in which they were registered.

##### Parameters:

Name | Type | Description
--- | --- | ---
`name` | string | The name of the hook.
`env` | Object.<string, any> | The environment variables of the hook passed to all callbacks registered.