Skip to content

code/CodeHighlightProvider

import { … } from 'zidane-ui'ui/src/code/CodeHighlightProvider.tsx

Components#

CodeHighlightProviderComponent#

Sets the highlighter and the code theme of every code block below.

TypeScript
function CodeHighlightProvider(props: CodeHighlightProviderProps): Element
Parameters
NameTypeDescription
propsCodeHighlightProviderProps

The CodeHighlightProviderProps.

Element
CodeHighlightProvider props
NameTypeDescription
childrenReactNode

The code blocks that read it.

highlighter?CodeHighlighter

The highlighter (its cache and worker). Default: the enclosing one, or a main-thread highlighter.

theme?string

A bundled code theme id. Default: the enclosing one, or the document's appearance's GitHub theme.

ui/src/code/CodeHighlightProvider.tsx:38

Functions#

useCodeHighlightFunction#

Returns the highlighter and the code theme in effect for a code block.

TypeScript
function useCodeHighlight(): { highlighter: CodeHighlighter; theme: string }
{ highlighter: CodeHighlighter; theme: string }

ui/src/code/CodeHighlightProvider.tsx:82

useDocumentAppearanceFunction#

The document's appearance: the .light class on <html>, else dark.

TypeScript
function useDocumentAppearance(watch?: boolean): Appearance
Parameters
NameTypeDefaultDescription
watch?booleantrue

Follow class changes. Off when the caller has its own theme and only needs a value.

ui/src/code/CodeHighlightProvider.tsx:77

Interfaces#

CodeHighlightProviderPropsInterface#

Props of CodeHighlightProvider.

TypeScript
interface CodeHighlightProviderProps
CodeHighlightProviderProps properties
NameTypeDescription
childrenReactNode

The code blocks that read it.

highlighter?CodeHighlighter

The highlighter (its cache and worker). Default: the enclosing one, or a main-thread highlighter.

theme?string

A bundled code theme id. Default: the enclosing one, or the document's appearance's GitHub theme.

ui/src/code/CodeHighlightProvider.tsx:24