summaryrefslogtreecommitdiff
path: root/localsvgtidy
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2014-12-01 10:04:38 +0100
committerJonas Smedegaard <dr@jones.dk>2014-12-01 10:04:38 +0100
commit8a3195b00ccd563fa492ea8a235a48a14f623b97 (patch)
treed55064e7efd542803b5a16ff5d8cd9d2ecabd2f0 /localsvgtidy
parent583b9d2ee43e6ec754d8be44d3889f580f6fd3f4 (diff)
Add new script localsvgtidy.
Diffstat (limited to 'localsvgtidy')
-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;