summaryrefslogtreecommitdiff
path: root/localsvgtidy
blob: 81021b0037fada3d946cb4544aeb854a53cd64e9 (plain)
  1. #!/usr/bin/perl
  2. # Copyright © 2014 Jonas Smedegaard <dr@jones.dk>
  3. # Description: optimize internal structure of SVG files
  4. #
  5. # This program is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 3, or (at your option)
  8. # any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful, but
  11. # WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. # General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. #
  18. # Depends: libxml-twig-perl
  19. #
  20. # TODO: Apply (the equivalent of) python-scour
  21. # TODO: Use TAB for indentation
  22. use warnings;
  23. use strict;
  24. use XML::Twig;
  25. my $twig = XML::Twig->new(
  26. keep_encoding => 1,
  27. keep_atts_order => 1,
  28. pretty_print => 'cvs',
  29. );
  30. if ( my $file= $ARGV[0] ) {
  31. $twig->parsefile( $file);
  32. } else {
  33. $twig->parse( \*STDIN);
  34. }
  35. $twig->flush;
  36. 1;