Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/pngwn/prism-svelte

Svelte language extension for prismjs
https://github.com/pngwn/prism-svelte

Last synced: 6 days ago
JSON representation

Svelte language extension for prismjs

Awesome Lists containing this project

README

        

# 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 = `

let count = 0;

count++ }>Hello

{ count }


    {#each Array(10).map((_, i) => i) as }
  • count = i}>Set count to {i}

  • {/each}

`;

const highlighted = Prism.highlight(source, Prism.languages.svelte, 'svelte');
```

[prismjs]: https://prismjs.com/