|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
619 bytes
|
| Line | |
|---|
| 1 | # svg-parser
|
|---|
| 2 |
|
|---|
| 3 | Take a string representing an SVG document or fragment, turn it into [HAST](https://github.com/syntax-tree/hast) JavaScript object.
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 | ## Installation
|
|---|
| 7 |
|
|---|
| 8 | `npm install svg-parser`, or grab it from [npmcdn.com/svg-parser](https://npmcdn.com/svg-parser).
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 | ## Usage
|
|---|
| 12 |
|
|---|
| 13 | ```js
|
|---|
| 14 | import { parse } from 'svg-parser';
|
|---|
| 15 |
|
|---|
| 16 | const parsed = parse( `
|
|---|
| 17 | <svg viewBox='0 0 100 100'>
|
|---|
| 18 | <!-- stuff goes here... -->
|
|---|
| 19 | </svg>
|
|---|
| 20 | ` );
|
|---|
| 21 | /*
|
|---|
| 22 | {
|
|---|
| 23 | type: 'root',
|
|---|
| 24 | children: [
|
|---|
| 25 | {
|
|---|
| 26 | type: 'element',
|
|---|
| 27 | tagName: 'svg',
|
|---|
| 28 | properties: {
|
|---|
| 29 | viewBox: '0 0 100 100'
|
|---|
| 30 | },
|
|---|
| 31 | children: [...]
|
|---|
| 32 | }
|
|---|
| 33 | ]
|
|---|
| 34 | }
|
|---|
| 35 | */
|
|---|
| 36 | ```
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 | ## License
|
|---|
| 40 |
|
|---|
| 41 | MIT
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.