summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xlocalsvgtidy43
1 files changed, 43 insertions, 0 deletions
diff --git a/localsvgtidy b/localsvgtidy
new file mode 100755
index 0000000..81021b0
--- /dev/null
+++ b/localsvgtidy
@@ -0,0 +1,43 @@
+#!/usr/bin/perl
+
+# Copyright © 2014 Jonas Smedegaard <dr@jones.dk>
+# Description: optimize internal structure of SVG files
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# Depends: libxml-twig-perl
+#
+# TODO: Apply (the equivalent of) python-scour
+# TODO: Use TAB for indentation
+
+use warnings;
+use strict;
+
+use XML::Twig;
+
+my $twig = XML::Twig->new(
+ keep_encoding => 1,
+ keep_atts_order => 1,
+ pretty_print => 'cvs',
+ );
+
+if ( my $file= $ARGV[0] ) {
+ $twig->parsefile( $file);
+} else {
+ $twig->parse( \*STDIN);
+}
+
+$twig->flush;
+
+1;