Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/patrickg/html-svelte-parser

HTML to Svelte parser.
https://github.com/patrickg/html-svelte-parser

dom html html-svelte-parser html-to-svelte parser svelte svelte-parser sveltekit

Last synced: 6 days ago
JSON representation

HTML to Svelte parser.

Awesome Lists containing this project

README

        

# html-svelte-parser Logo html-svelte-parser

HTML to Svelte parser that works on both the server (Node.js) and the client (browser).

To replace an element with a svelte component, check out the [`processNode`](#processnode) option.

#### Example

_Paragraph.svelte_

```svelte


```

_App.svelte_

```svelte

import { Html, isTag } from 'html-svelte-parser';
import Paragraph from './Paragraph.svelte';

{
if (isTag(node) && node.name === 'p') {
return { component: Paragraph };
}
}}
/>

```

---

Table of Contents

- [Install](#install)
- [Usage](#usage)
- [processNode](#processnode)
- [Modify/remove nodes](#modifyremove-nodes)
- [Replace nodes](#replace-nodes)
- [Usage with sveltekit](#usage-with-sveltekit)
- [Named slots](#named-slots)
- [Credits](#credits)

## Install

Install the [NPM package _html-svelte-parser_](https://www.npmjs.com/package/html-svelte-parser) with your favorite package manager:

```sh
npm install html-svelte-parser
# pnpm add html-svelte-parser
# yarn add html-svelte-parser
```

## Usage

```svelte

import { Html } from 'html-svelte-parser';