Special SVG content cannot be cleaned up
duowb opened this issue · 3 comments
duowb commented
import { SVG, cleanupSVG } from "@iconify/tools";
const reallyBadIcon = `<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1649832310065"
class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1294"
xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200">
<defs>
<style type="text/css">
@font-face {
font-family: feedback-iconfont;
src: url("//at.alicdn.com/t/font_1031158_u69w8yhxdu.woff2?t=1630033759944") format("woff2"), url("//at.alicdn.com/t/font_1031158_u69w8yhxdu.woff?t=1630033759944") format("woff"), url("//at.alicdn.com/t/font_1031158_u69w8yhxdu.ttf?t=1630033759944") format("truetype");
}
</style>
</defs>
<path
d="M393.142857 548.571429A82.285714 82.285714 0 0 1 475.428571 630.857143v201.142857A82.285714 82.285714 0 0 1 393.142857 914.285714h-201.142857A82.285714 82.285714 0 0 1 109.714286 832v-201.142857A82.285714 82.285714 0 0 1 192 548.571429h201.142857z m438.857143 0A82.285714 82.285714 0 0 1 914.285714 630.857143v201.142857A82.285714 82.285714 0 0 1 832 914.285714h-201.142857A82.285714 82.285714 0 0 1 548.571429 832v-201.142857A82.285714 82.285714 0 0 1 630.857143 548.571429h201.142857z m-438.857143 54.857142h-201.142857a27.428571 27.428571 0 0 0-27.428571 27.428572v201.142857c0 15.140571 12.288 27.428571 27.428571 27.428571h201.142857a27.428571 27.428571 0 0 0 27.428572-27.428571v-201.142857a27.428571 27.428571 0 0 0-27.428572-27.428572z m438.857143 0h-201.142857a27.428571 27.428571 0 0 0-27.428572 27.428572v201.142857c0 15.140571 12.288 27.428571 27.428572 27.428571h201.142857a27.428571 27.428571 0 0 0 27.428571-27.428571v-201.142857a27.428571 27.428571 0 0 0-27.428571-27.428572zM393.142857 109.714286A82.285714 82.285714 0 0 1 475.428571 192v201.142857A82.285714 82.285714 0 0 1 393.142857 475.428571h-201.142857A82.285714 82.285714 0 0 1 109.714286 393.142857v-201.142857A82.285714 82.285714 0 0 1 192 109.714286h201.142857z m438.857143 0A82.285714 82.285714 0 0 1 914.285714 192v201.142857A82.285714 82.285714 0 0 1 832 475.428571h-201.142857A82.285714 82.285714 0 0 1 548.571429 393.142857v-201.142857A82.285714 82.285714 0 0 1 630.857143 109.714286h201.142857z m-438.857143 54.857143h-201.142857a27.428571 27.428571 0 0 0-27.428571 27.428571v201.142857c0 15.140571 12.288 27.428571 27.428571 27.428572h201.142857a27.428571 27.428571 0 0 0 27.428572-27.428572v-201.142857a27.428571 27.428571 0 0 0-27.428572-27.428571z m438.857143 0h-201.142857a27.428571 27.428571 0 0 0-27.428572 27.428571v201.142857c0 15.140571 12.288 27.428571 27.428572 27.428572h201.142857a27.428571 27.428571 0 0 0 27.428571-27.428572v-201.142857a27.428571 27.428571 0 0 0-27.428571-27.428571z"
p-id="1295"></path>
</svg>`;
(async () => {
const svg = new SVG(reallyBadIcon);
console.log(svg.getBody())
await cleanupSVG(svg);
console.log(svg.toMinifiedString());
})();
Do I have to delete style
manually?
cyberalien commented
That function doesn't have complex css parser, so it wouldn't know what to do with @font-face
. I haven't encountered such icons yet.
I'll see what can be done about that.
cyberalien commented
Fixed in 2.1.0-beta.6
.
Run npm install @iconify/tools@next
to install it.
duowb commented
You are amazing, like a superman! 👍