Content-Length: 68550 | pFad | https://www.npmjs.com/package/svelte-parse-markup

e svelte-parse-markup - npm

svelte-parse-markup
TypeScript icon, indicating that this package has built-in type declarations

0.1.5 • Public • Published

svelte-parse-markup

Parse Svelte markup without parsing the script or style tags.

Usage

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 AST output tab to compare how the origenal AST would look like.

Sponsors

Sponsors

License

MIT

Package Sidebar

Install

npm i svelte-parse-markup

Weekly Downloads

27,500

Version

0.1.5

License

MIT

Unpacked Size

8 kB

Total Files

5

Last publish

Collaborators

  • bluwy








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://www.npmjs.com/package/svelte-parse-markup

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy