A tiny wrapper over posthml with the same API optimized for working with SVG
npm install postsvgA tiny wrapper over posthtml with the same
API optimized for working with SVG.
- Content is parsed in xml mode.
- Properly renders SVG self-closing tags (, etc).
- Processing result is instance of Tree class which is wrapper
around Array and backward compatible with posthtml parser.
PostSVG tree has several useful methods for work with AST:
``js
const { parse } = require('postsvg');
const tree = parse('');
/**
* root getter returns
/**
* Find all
* @return {Array
*/
tree.select('path');
/**
* Select only nodes with class="qwe"
* @return {Array
*/
tree.select('.qwe');
/**
* Fill each
*/
tree.each('path', node => node.attrs.fill = 'red');
`
Node has following structure:
```
Node<{
tag: string,
attrs?: Object,
content?: Array
}>