2022-08-02 14:53:18 -05: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-25 22:34:13 -05:00
|
|
|
import { Prism } from '@astrojs/prism';
|
2022-08-02 14:53:18 -05: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-25 22:34:13 -05:00
|
|
|
runHighlighterWithAstro(
|
|
|
|
`
|
2022-08-02 14:53:18 -05:00
|
|
|
---
|
|
|
|
const helloAstro = 'Hello, Astro!';
|
|
|
|
---
|
|
|
|
|
|
|
|
<div>{helloAstro}</div>
|
2023-06-25 22:34:13 -05:00
|
|
|
`,
|
|
|
|
'astro',
|
|
|
|
);
|
2022-08-02 14:53:18 -05:00
|
|
|
```
|