2022-08-02 19:53:18 +00:00
|
|
|
# @astrojs/prism
|
|
|
|
|
|
|
|
Supports Prism highlighting in Astro projects
|
|
|
|
|
|
|
|
## Component
|
|
|
|
|
|
|
|
This package exports a component to support highlighting inside an Astro file. Example:
|
|
|
|
|
|
|
|
```astro
|
|
|
|
---
|
2023-06-26 03:34:13 +00:00
|
|
|
import { Prism } from '@astrojs/prism';
|
2022-08-02 19:53:18 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
<Prism lang="js" code={`const foo = 'bar';`} />
|
|
|
|
```
|
|
|
|
|
|
|
|
## Internal
|
|
|
|
|
|
|
|
This package exports a `runHighlighterWithAstro` function to highlight while making sure the Astro language is loaded beforehand
|
|
|
|
|
|
|
|
```typescript
|
|
|
|
import { runHighlighterWithAstro } from '@astrojs/prism';
|
|
|
|
|
2023-06-26 03:34:13 +00:00
|
|
|
runHighlighterWithAstro(
|
|
|
|
`
|
2022-08-02 19:53:18 +00:00
|
|
|
---
|
|
|
|
const helloAstro = 'Hello, Astro!';
|
|
|
|
---
|
|
|
|
|
|
|
|
<div>{helloAstro}</div>
|
2023-06-26 03:34:13 +00:00
|
|
|
`,
|
|
|
|
'astro'
|
|
|
|
);
|
2022-08-02 19:53:18 +00:00
|
|
|
```
|