Urara-Blog/node_modules/.pnpm-store/v3/files/79/6f00ca0d7eae228c9521b9bd0357f2a0409282f60300a9e1417c993683bbe304eca38b4df0ce28404e953ae56c9988371f605876e46b5a0c158df5fcf246bd
2022-08-14 01:14:53 +08:00

38 lines
668 B
Text

# prism-svelte
Syntax highlighting for svelte code with [prismjs].
## install
```bash
npm i prism-svelte # or yarn add prism-svelte
```
## Usage
Import `prismjs` then import `prism-svelte` (the order is very important) and it should work:
```js
import Prism from 'prismjs';
import 'prism-svelte';
const source = `
<script>
let count = 0;
</script>
<button on:click={ () => count++ }>Hello</button>
<h1>{ count }</h1>
<ul>
{#each Array(10).map((_, i) => i) as }
<li on:click={() => count = i}>Set count to {i}</li>
{/each}
</ul>
`;
const highlighted = Prism.highlight(source, Prism.languages.svelte, 'svelte');
```
[prismjs]: https://prismjs.com/