-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
27 lines (24 loc) · 769 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
'use strict';
const AutocropUtils = require('./lib/AutocropUtils');
exports.type = 'visitor';
exports.name = 'autocrop';
exports.active = true;
exports.description = 'reduce viewBox to minimum possible size so no wasted transparent space around svg';
/**
* Reduce viewBox to minimum possible size so no wasted transparent space around svg.
*
* @example
* <svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
* <rect x="5" y="5" width="10" height="10" fill="#000"/>
* </svg>
* ⬇
* <svg viewBox="0 0 10 10" xmlns="http://www.w3.org/2000/svg">
* <rect x="0" y="0" width="10" height="10" fill="#000"/>
* </svg>
*
* @author Glennos
*/
exports.fn = (ast, params, info) => {
AutocropUtils.plugin(ast, params, info);
return null;
};