Skip to content

forEachCodeBlock

forEachCodeBlock<T>(root, callback): PrismCodeBlock[]

Defined in: client/code-block.ts:34

Runs a callback function for each code block under the root in document order. If a callback has previously been run for a code block, it’s skipped.

The callback function takes the code block as the first argument. The second parameter is any additional properties passed when the code block was created. These options were stringified to JSON and parsed.

T extends object

Root to search for code blocks under.

Element | Document

(codeBlock, options) => void

Function to run for each code block.

PrismCodeBlock[]

An array with all visited code blocks in document order.