LineNumbers

Renders line numbers for the CodeBlock component.

API Reference

LineNumbers

(props: LineNumbersProps) => JSX.Element

Renders line numbers for the CodeBlock component.

Parameters
LineNumbersProps
Returns
Element

calculateLinesToHighlight

(ranges: string | undefined) => (index: number) => boolean

Calculate which lines to highlight based on the range meta string added by the rehype plugin.

Parameters

ranges *

string | undefined
Returns
(index: number) => boolean

LineNumbersProps

LineNumbersProps
Properties

tokens

Array<Array<Token>> | undefined

Tokens to render from getTokens.

highlightRanges

string | undefined

A string of comma separated lines and ranges to highlight.

css

CSSObject | undefined

CSS object to apply to the line numbers container.

className

string | undefined

Class name to apply to the line numbers container.

style

React.CSSProperties | undefined

Style to apply to the line numbers container.