#! /usr/bin/perl
use strict;
use warnings;
use MIME::Base64;

undef $/;
my $x = <>;
$x = MIME::Base64::decode_base64($x);
$x =~ s/>\s*</></sg;  # Remove whitespace between tags.
$x =~ s/\s+/ /sg;  # Compress whitespace.
$x =~ s# />#/>#g;  # <foo /> -> <foo/>.
$x =~ s/;\s+/;/sg; # Remove whitespace in CSS.
$x =~ s/;"/"/g;   # Remove final semicolon in CSS.
$x =~ s/\s+$//;  # Remove tailing whitespace.
$x =~ s/><!DOCTYPE/>\n<!DOCTYPE/;  # Add back newline after XML header.
$x =~ s/<svg/\n<svg/;   # Add back newline after DOCTYPE.

print $x, "\n";
print MIME::Base64::encode_base64($x, ""), "\n";
