-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.js
31 lines (26 loc) · 848 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
28
29
30
31
module.exports = function(content) {
this.cacheable && this.cacheable();
var match = content.match(/<svg([^>]+)+>([\s\S]+)<\/svg>/i);
var attrs = {};
if (match) {
attrs = match[1];
if (attrs) {
attrs = attrs.match(/([\w-:]+)(=)?("[^<>"]*"|'[^<>']*'|[\w-:]+)/g)
.reduce(function(obj, attr){
var split = attr.split('=');
var name = split[0];
var value = true;
if (split && split[1]) {
value = split[1].replace(/['"]/g, '');
}
obj[name] = value;
return obj;
}, {})
}
content = match[2] || '';
};
content = content.replace(/\n/g, ' ').trim();
this.value = content;
return "module.exports = " + JSON.stringify({attributes: attrs, content: content});
}
module.exports.seperable = true;