From 8a3195b00ccd563fa492ea8a235a48a14f623b97 Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Mon, 1 Dec 2014 10:04:38 +0100 Subject: Add new script localsvgtidy. --- localsvgtidy | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100755 localsvgtidy (limited to 'localsvgtidy') 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 +# 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 . +# +# 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; -- cgit v1.2.3