svg-parser
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/svg-parser package

2.0.4 • Public • Published

svg-parser

Take a string representing an SVG document or fragment, turn it into HAST JavaScript object.

Installation

npm install svg-parser, or grab it from npmcdn.com/svg-parser.

Usage

import { parse } from 'svg-parser';
 
const parsed = parse( `
    <svg viewBox='0 0 100 100'>
        <!-- stuff goes here... -->
    </svg>
` );
/*
{
  type: 'root',
  children: [
    {
      type: 'element',
      tagName: 'svg',
      properties: {
        viewBox: '0 0 100 100'
      },
      children: [...]
    }
  ]
}
*/

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i svg-parser

Weekly Downloads

6,789,239

Version

2.0.4

License

MIT

Unpacked Size

48.9 kB

Total Files

9

Last publish

Collaborators

  • rich_harris
  • trysound