iconic / illustrator-svg-exporter

A better way to generate SVGs from Illustrator.
603 stars 45 forks source link

Run regex on exported SVGs to sanitize #9

Open somerandomdude opened 9 years ago

somerandomdude commented 9 years ago

See example:

svg = File(doc.path+"exported.svg");

css = "css/style.css";

svg.open('r');

xml = file.read().replace(/^<g[^\n]+\.svg">(.*)<.g>/g,"$1");
xml = xml.replace(/(g|path) id=['\"](?!_x23_)/g,'$1 class="').replace(/_x2._/g,'');

svg.close(); file.open('w');//e

svg.write('<?xml-stylesheet type="text/css" href="'+css+'"?>\n'+xml);//writeln

svg.close();