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