How the Highlight children function works
masterThe <Highlight /> component uses a render-props pattern. The function passed as children receives an object containing state and prop getters.
State
tokens(Token[][]): A doubly nested array. The outer array represents lines, and the inner array containsTokenobjects. ATokenhastypes(array of strings) andcontent(the text).className(string): The CSS class to apply to the wrapping element (e.g., a<pre>).
Prop Getters
These functions return props that should be spread onto your elements to ensure correct styling and class names.
getLineProps({ line }): Returns props for a line element (typically a<div>). It includes a.token-lineclass and merges styles/classes.getTokenProps({ token }): Returns props for a token element (typically a<span>). It includes a.tokenclass and merges styles/classes.