# svelte-parse-markup

> Parse Svelte markup without parsing the script or style tags

Latest version **0.1.5** (published 2024-06-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install svelte-parse-markup
pnpm add svelte-parse-markup
yarn add svelte-parse-markup
bun add svelte-parse-markup
```

## Health

**Score 40/100 (D)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.1.5 |
| Published | 2024-06-04 |
| First published | 2022-10-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Dependencies | 0 |
| Unpacked size | 7.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | Bjorn Lu |
| Maintainers | bluwy |
| Keywords | svelte, parse, markup, script, style |

## Links

- npm: https://www.npmjs.com/package/svelte-parse-markup
- Repository: https://github.com/bluwy/svelte-parse-markup
- Issues: https://github.com/bluwy/svelte-parse-markup/issues
- Funding: https://bjornlu.com/sponsor
- npm.io page: https://npm.io/package/svelte-parse-markup

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 0.1.5 (latest) — 2024-06-04
- 0.1.4 — 2024-05-20
- 0.1.3 — 2024-05-18
- 0.1.2 — 2023-06-23
- 0.1.1 — 2022-10-02
- 0.1.0 — 2022-10-02

## README

# svelte-parse-markup

Parse Svelte markup without parsing the script or style tags.

## Usage

```js
import { parse } from 'svelte-parse-markup'

const ast = parse('some svelte code')

console.log(ast.instance.content.body)
// output:
// [
//   {
//     type: 'Text',
//     start: <num>,
//     end: <num>,
//     raw: 'instance script content',
//     content: 'instance script content'
//   }
// ]

console.log(ast.module.content.body)
// output:
// [
//   {
//     type: 'Text',
//     start: <num>,
//     end: <num>,
//     raw: 'module script content',
//     content: 'module script content'
//   }
// ]

console.log(ast.css.content.styles)
console.log(ast.css.children)
// output:
// 'css content'
// [
//   {
//     type: 'Text',
//     start: <num>,
//     end: <num>,
//     raw: 'css content',
//     content: 'css content'
//   }
// ]
```

`svelte-parse-markup` skips parsing scripts and styles, and injects a `Text` node instead. Check out the [Svelte REPL](https://svelte.dev/repl) AST output tab to compare how the original AST would look like.

## Sponsors

<p align="center">
  <a href="https://bjornlu.com/sponsor">
    <img src="https://bjornlu.com/sponsors.svg" alt="Sponsors" />
  </a>
</p>

## License

MIT

---
_Source: https://npm.io/package/svelte-parse-markup · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
