123456789101112131415161718192021222324252627282930313233343536373839 |
- 'use strict';
- exports.name = 'convertEllipseToCircle';
- exports.type = 'visitor';
- exports.active = true;
- exports.description = 'converts non-eccentric <ellipse>s to <circle>s';
- exports.fn = () => {
- return {
- element: {
- enter: (node) => {
- if (node.name === 'ellipse') {
- const rx = node.attributes.rx || '0';
- const ry = node.attributes.ry || '0';
- if (
- rx === ry ||
- rx === 'auto' ||
- ry === 'auto'
- ) {
- node.name = 'circle';
- const radius = rx === 'auto' ? ry : rx;
- delete node.attributes.rx;
- delete node.attributes.ry;
- node.attributes.r = radius;
- }
- }
- },
- },
- };
- };
|