dromara/newcar

Feat: `transform` function to parse svg string to svg tree

sheepbox8646 opened this issue · 0 comments

We define many interfaces in ./mods/mod-svg, please write a function, which can parse svg string to a svg tree (SVGItem[])

The entry type is defined in https://github.com/dromara/newcar/blob/main/mods/mod-svg/src/elements/index.ts, please recognize the type and tag attribute of a SVGItem

please write it in mods\mod-svg\src\transform.ts, the function name is transform

If you are interested in this issue and have ability to implement it, please comment under the issue.

Example

const tree = transform('<circle cx="50" cy="50" r="50" />')
console.log(tree) // { tag: 'Circle', type: 'Graphics', props: { cx: 50, cy: 50, r: 50 }, children: [] }

Note: The tag name's first word is a upper format

Warn: Don't use DOMParser or another only-browser API!