{:html}` and `{:html}` elements will have the data attribute
`data-theme="...themes"`, listing each theme value space-separated:
```html
```
## Visitor Hooks
To customize the HTML output, you can use visitor callback hooks to manipulate
the [hAST elements](https://github.com/syntax-tree/hast#element) directly:
```js
const options = {
onVisitLine(element) {
console.log("Visited line");
},
onVisitHighlightedLine(element) {
console.log("Visited highlighted line");
},
onVisitHighlightedChars(element) {
console.log("Visited highlighted chars");
},
onVisitTitle(element) {
console.log("Visited title");
},
onVisitCaption(element) {
console.log("Visited caption");
},
};
```
## Custom Highlighter
To completely configure the highlighter, use the
`getHighlighter{:.entity.name.function}` option. This is helpful if you'd like
to configure other Shiki options, such as `langs{:.meta.object-literal.key}`.
```js
import { getHighlighter } from "shiki";
const options = {
getHighlighter: (options) =>
getHighlighter({
...options,
langs: [
"plaintext",
async () => JSON.parse(await readFile("my-grammar.json", "utf-8")),
],
}),
};
```
## React Server Component
The [usage](#usage) works directly in React Server Components. Here's an example:
```tsx title="code.tsx"
import * as React from "react";
import { unified } from "unified";
import remarkParse from "remark-parse";
import remarkRehype from "remark-rehype";
import rehypeStringify from "rehype-stringify";
import rehypePrettyCode from "rehype-pretty-code";
export async function Code({ code }: { code: string }) {
const highlightedCode = await highlightCode(code);
return (
);
}
async function highlightCode(code: string) {
const file = await unified()
.use(remarkParse)
.use(remarkRehype)
.use(rehypePrettyCode, {
keepBackground: false,
})
.use(rehypeStringify)
.process(code);
return String(file);
}
```
Then, import the RSC into a page or another component:
```tsx src/app/rsc/page.tsx
import * as React from "react";
import { Code } from "./code.tsx";
export default async function Page() {
return (
);
}
```
See this example in action at [/rsc](/rsc).