HTML-Packer-2.02/ 000755 000765 000024 00000000000 12651452011 014710 5 ustar 00leejohnson staff 000000 000000 HTML-Packer-2.02/.cvsignore 000644 000765 000024 00000000251 12534004166 016712 0 ustar 00leejohnson staff 000000 000000 /blib*
/Makefile
/Makefile.old
/Makefile.bak
/MANIFEST.bak
/META.yml
/MYMETA.yml
/Build
/_build*
/pm_to_blib*
/*.tar.gz
/HTML-Packer-*
/t/html/*-got.html
/inc
.DS_Store
HTML-Packer-2.02/.gitignore 000644 000765 000024 00000000266 12534004623 016706 0 ustar 00leejohnson staff 000000 000000 /blib*
/Makefile
/Makefile.old
/Makefile.bak
/MANIFEST.bak
/META.yml
/MYMETA.yml
/MYMETA.json
/Build
/_build*
/pm_to_blib*
/*.tar.gz
/HTML-Packer-*
/t/html/*-got.html
/inc
.DS_Store
HTML-Packer-2.02/Changes 000644 000765 000024 00000004441 12651451734 016221 0 ustar 00leejohnson staff 000000 000000 Revision history for HTML-Packer
2.02 2016-02-25
- Fix: memory leak due to reference cycles in reggrp_data closures
2.01 2016-01-13
- Fix: newlines should pack to spaces as per W3C (thanks to basbloemsaat)
2.00 2015-06-04
- New maintainer: LEEJO
- Repoint issue tracker/repo at leejo's fork
- Add .travis.yml for CI goodness
- Add Changes test
- Add MYMETA.json to .gitignore
1.004001 2012-02-20
- Use gnutar to build distribution.
1.004 2011-09-27
- Raised version number.
1.003_001 2011-08-19
- Replaced map with foreach.
- Fixed bug in html5 handling. Thanks to Brian Cassidy.
1.002001 2011-06-15
- Fixed embarrassing bug in comment regexp.
- Fixed tests.
- Added TODO.
1.002 2011-06-07
- Raised version number.
1.001_002 2011-05-20
- Fixed tests. Thanks to Kent Fredric.
- Changed possible values for do_javascript options.
1.001_001 2011-04-12
- Added html5 option.
- Removed no_cdata option.
- Added tests.
- Minor bugfixes.
- Cleanup.
1.001001 2011-03-07
- Changed requirements to Regexp::RegGrp 1.000001 due to "undefined submatches bug" in Regexp::RegGrp.
- Added accessors.
- Added tests.
1.000 2011-01-17
- Changed versioning.
- Raised major version due to changes in versioning.
- Changed requirements to Regexp::RegGrp 1.000 due to changes in versioning.
0.05_06 2011-01-05
- Changed requirements to Regexp::RegGrp 0.04.
0.05_05 2010-12-03
- Added no_cdata option.
0.05_04 2010-10-05
- Changed required perl version to 5.8.9.
0.05_03 2010-09-21
- Added option to switch off compression via comment.
- Added support for conditional comments.
- Changed requirements to Regexp::RegGrp 0.0203
- Added tests.
0.05_02 2010-09-13
- Changed requirements to Regexp::RegGrp 0.0201
0.05_01 2009-02-15
- Moved regexp grouping stuff to Regexp::RegGrp.
- Added object-oriented interface.
- Switched tabs to soft tabs.
- Switched to Module::Install.
0.4 2009-02-15
- Another embarrassing typo fix in documentation
- Updated README file
0.3 2009-02-11
- Typo fix in documentation
0.2 2009-02-10
- Added some tests
0.1 2009-02-09
- First version, released on an unsuspecting world.
HTML-Packer-2.02/MANIFEST 000644 000765 000024 00000001261 12534004341 016040 0 ustar 00leejohnson staff 000000 000000 .cvsignore
.gitignore
Changes
inc/Module/AutoInstall.pm
inc/Module/Install.pm
inc/Module/Install/AutoInstall.pm
inc/Module/Install/Base.pm
inc/Module/Install/Can.pm
inc/Module/Install/Fetch.pm
inc/Module/Install/Include.pm
inc/Module/Install/Makefile.pm
inc/Module/Install/Metadata.pm
inc/Module/Install/Win32.pm
inc/Module/Install/WriteAll.pm
lib/HTML/Packer.pm
Makefile.PL
MANIFEST
META.yml
README.md
t/00-load.t
t/01-interface.t
t/02-io.t
t/html/s1-expected.html
t/html/s1.html
t/html/s2-expected.html
t/html/s2.html
t/html/s3-expected.html
t/html/s3.html
t/html/s4-expected.html
t/html/s4.html
t/html/s5-expected.html
t/html/s5.html
t/html/s6-expected.html
t/html/s6.html
t/pod.t
TODO
HTML-Packer-2.02/META.yml 000644 000765 000024 00000001351 12651452005 016164 0 ustar 00leejohnson staff 000000 000000 ---
abstract: 'Another HTML code cleaner'
author:
- 'Merten Falk, C<< >>. Now maintained by Lee'
build_requires:
ExtUtils::MakeMaker: 6.59
Test::More: 0
configure_requires:
ExtUtils::MakeMaker: 6.59
distribution_type: module
dynamic_config: 1
generated_by: 'Module::Install version 1.16'
license: perl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: 1.4
module_name: HTML::Packer
name: HTML-Packer
no_index:
directory:
- inc
- t
requires:
Regexp::RegGrp: 1.001_001
perl: 5.8.9
resources:
bugtracker: http://github.com/leejo/html-packer-perl/issues
license: http://dev.perl.org/licenses/
repository: http://github.com/leejo/html-packer-perl
version: '2.02'
HTML-Packer-2.02/Makefile.PL 000644 000765 000024 00000000560 12534004761 016670 0 ustar 00leejohnson staff 000000 000000 use strict;
use warnings;
use inc::Module::Install;
all_from 'lib/HTML/Packer.pm';
test_requires 'Test::More' => 0;
requires 'Regexp::RegGrp' => "1.001_001";
repository 'http://github.com/leejo/html-packer-perl';
bugtracker 'http://github.com/leejo/html-packer-perl/issues';
clean_files 't/html/s?-got.html';
auto_install();
WriteAll();
HTML-Packer-2.02/README.md 000644 000765 000024 00000005234 12645465453 016214 0 ustar 00leejohnson staff 000000 000000 # NAME
HTML::Packer - Another HTML code cleaner
# VERSION
Version 2.01
# DESCRIPTION
A HTML Compressor.
# SYNOPSIS
use HTML::Packer;
my $packer = HTML::Packer->init();
$packer->minify( $scalarref, $opts );
To return a scalar without changing the input simply use (e.g. example 2):
my $ret = $packer->minify( $scalarref, $opts );
For backward compatibility it is still possible to call 'minify' as a function:
HTML::Packer::minify( $scalarref, $opts );
First argument must be a scalarref of HTML-Code.
Second argument must be a hashref of options. Possible options are
- remove\_comments
HTML-Comments will be removed if 'remove\_comments' has a true value.
- remove\_newlines
ALL newlines will be removed if 'remove\_newlines' has a true value.
- do\_javascript
Defines compression level for javascript. Possible values are 'clean', 'obfuscate', 'shrink' and 'best'.
Default is no compression for javascript.
This option only takes effect if [JavaScript::Packer](https://metacpan.org/pod/JavaScript::Packer) is installed.
- do\_stylesheet
Defines compression level for CSS. Possible values are 'minify' and 'pretty'.
Default is no compression for CSS.
This option only takes effect if [CSS::Packer](https://metacpan.org/pod/CSS::Packer) is installed.
- no\_compress\_comment
If not set to a true value it is allowed to set a HTML comment that prevents the input being packed.
Is not set by default.
- html5
If set to a true value closing slashes will be removed from void elements.
# AUTHOR
Merten Falk, ``. Now maintained by Lee
Johnson (LEEJO).
# BUGS
Please report any bugs or feature requests through
the web interface at [https://github.com/leejo/html-packer-perl/issues](https://github.com/leejo/html-packer-perl/issues). I will be notified, and then you'll
automatically be notified of progress on your bug as I make changes.
# SUPPORT
You can find documentation for this module with the perldoc command.
perldoc HTML::Packer
# COPYRIGHT & LICENSE
Copyright 2009 - 2011 Merten Falk, all rights reserved.
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
# SEE ALSO
[HTML::Clean](https://metacpan.org/pod/HTML::Clean)
HTML-Packer-2.02/TODO 000644 000765 000024 00000000051 12534004166 015400 0 ustar 00leejohnson staff 000000 000000 2011-06-15
- More tests.
- Better tests. HTML-Packer-2.02/inc/ 000755 000765 000024 00000000000 12651452011 015461 5 ustar 00leejohnson staff 000000 000000 HTML-Packer-2.02/lib/ 000755 000765 000024 00000000000 12651452011 015456 5 ustar 00leejohnson staff 000000 000000 HTML-Packer-2.02/t/ 000755 000765 000024 00000000000 12651452011 015153 5 ustar 00leejohnson staff 000000 000000 HTML-Packer-2.02/t/00-load.t 000644 000765 000024 00000000222 12534004166 016474 0 ustar 00leejohnson staff 000000 000000 #!perl -T
use Test::More tests => 1;
BEGIN {
use_ok( 'HTML::Packer' );
}
diag( "Testing HTML::Packer $HTML::Packer::VERSION, Perl $], $^X" );
HTML-Packer-2.02/t/01-interface.t 000644 000765 000024 00000011070 12534004166 017521 0 ustar 00leejohnson staff 000000 000000 #!perl -T
use Test::More;
my $not = 39;
SKIP: {
eval { use HTML::Packer; };
skip( 'HTML::Packer not installed!', $not ) if ( $@ );
plan tests => $not;
my $packer = HTML::Packer->init();
ok( ! $packer->remove_comments(), 'Default value for remove_comments.' );
ok( ! $packer->remove_newlines(), 'Default value for remove_newlines.' );
ok( ! $packer->no_compress_comment(), 'Default value for no_compress_comment.' );
ok( ! $packer->html5(), 'Default value for no_cdata.' );
ok( ! $packer->do_javascript(), 'Default value for do_javascript.' );
ok( ! $packer->do_stylesheet(), 'Default value for do_stylesheet.' );
$packer->remove_comments( 1 );
ok( $packer->remove_comments(), 'Set remove_comments.' );
$packer->remove_comments( 0 );
ok( ! $packer->remove_comments(), 'Unset remove_comments.' );
$packer->remove_newlines( 1 );
ok( $packer->remove_newlines(), 'Set remove_newlines.' );
$packer->remove_newlines( 0 );
ok( ! $packer->remove_newlines(), 'Unset remove_newlines.' );
$packer->no_compress_comment( 1 );
ok( $packer->no_compress_comment(), 'Set no_compress_comment.' );
$packer->no_compress_comment( 0 );
ok( ! $packer->no_compress_comment(), 'Unset no_compress_comment.' );
$packer->html5( 1 );
ok( $packer->html5(), 'Set html5.' );
$packer->html5( 0 );
ok( ! $packer->html5(), 'Unset html5.' );
$packer->do_javascript( 'clean' );
is( $packer->do_javascript(), 'clean', 'Set do_javascript to "clean".' );
$packer->do_javascript( 'shrink' );
is( $packer->do_javascript(), 'shrink', 'Set do_javascript to "shrink".' );
$packer->do_javascript( 'obfuscate' );
is( $packer->do_javascript(), 'obfuscate', 'Set do_javascript to "obfuscate".' );
$packer->do_javascript( 'foo' );
is( $packer->do_javascript(), 'obfuscate', 'Setting do_javascript to "foo" failed.' );
$packer->do_javascript( '' );
ok( ! $packer->do_javascript(), 'Unset do_javascript.' );
$packer->do_javascript( 'bar' );
ok( ! $packer->do_javascript(), 'Setting do_javascript to "bar" failed.' );
$packer->do_stylesheet( 'minify' );
is( $packer->do_stylesheet(), 'minify', 'Set do_stylesheet to "minify".' );
$packer->do_stylesheet( 'pretty' );
is( $packer->do_stylesheet(), 'pretty', 'Set do_stylesheet to "pretty".' );
$packer->do_stylesheet( 'foo' );
is( $packer->do_stylesheet(), 'pretty', 'Setting do_stylesheet to "foo" failed.' );
$packer->do_stylesheet( '' );
ok( ! $packer->do_stylesheet(), 'Unset do_stylesheet.' );
$packer->do_stylesheet( 'bar' );
ok( ! $packer->do_stylesheet(), 'Setting do_stylesheet to "bar" failed.' );
eval "use JavaScript::Packer $HTML::Packer::REQUIRED_JAVASCRIPT_PACKER;";
if ( $@ ) {
ok( ! $packer->javascript_packer(), 'JavaScript::Packer >= ' . $HTML::Packer::REQUIRED_JAVASCRIPT_PACKER . ' not installed.' );
}
else {
isa_ok( $packer->javascript_packer(), 'JavaScript::Packer', 'JavaScript::Packer installed.' );
}
eval "use CSS::Packer $HTML::Packer::REQUIRED_CSS_PACKER;";
if ( $@ ) {
ok( ! $packer->css_packer(), 'CSS::Packer >= ' . $HTML::Packer::REQUIRED_CSS_PACKER . ' not installed.' );
}
else {
isa_ok( $packer->css_packer(), 'CSS::Packer', 'CSS::Packer installed.' );
}
my $str = '';
$packer->minify( \$str, {} );
ok( ! $packer->remove_comments(), 'Default value for remove_comments is still set.' );
ok( ! $packer->remove_newlines(), 'Default value for remove_newlines is still set.' );
ok( ! $packer->no_compress_comment(), 'Default value for no_compress_comment is still set.' );
ok( ! $packer->html5(), 'Default value for html5 is still set.' );
ok( ! $packer->do_javascript(), 'Default value for do_javascript is still set.' );
ok( ! $packer->do_stylesheet(), 'Default value for do_stylesheet is still set.' );
$packer->minify(
\$str,
{
remove_comments => 1,
remove_newlines => 1,
no_compress_comment => 1,
html5 => 1,
do_javascript => 'clean',
do_stylesheet => 'minify'
}
);
ok( $packer->remove_comments(), 'Set remove_comments again.' );
ok( $packer->remove_newlines(), 'Set remove_newlines again.' );
ok( $packer->no_compress_comment(), 'Set no_compress_comment again.' );
ok( $packer->html5(), 'Set html5 again.' );
ok( $packer->do_javascript(), 'Set do_javascript to "clean" again.' );
ok( $packer->do_stylesheet(), 'Set do_stylesheet to "minify" again.' );
} HTML-Packer-2.02/t/02-io.t 000644 000765 000024 00000014555 12645465332 016215 0 ustar 00leejohnson staff 000000 000000 #!perl -T
# =========================================================================== #
use Test::More;
my $js_input = <
alert('test');
link
1 < /a>
< a href="/"> link 2
< / a >
EOT
my $js_expected = ' link 1 link 2 ';
my $js_expected_html5 = ' link 1 link 2 ';
my $js_expected_html5_no_js = ' link 1 link 2 ';
my $js_expected_no_js = ' link 1 link 2 ';
my $css_input = <
foo {
asdf:asdf;
ew:12;
}
link
1 < /a>
< a href="/"> link 2
< / a >
EOT
my $css_expected = ' link 1 link 2 ';
my $css_expected_no_css = ' link 1 link 2 ';
my $css_expected_html5 = ' link 1 link 2 ';
my $css_expected_html5_no_css = ' link 1 link 2 ';
my $html_input = </**/
link
1 < /a>
< a href="/"> link 2
< / a >
EOT
my $html_expected = '
link 1 link 2 ';
my $html_expected_no_js = '
link 1 link 2 ';
my $not = 11;
SKIP: {
eval { use HTML::Packer; };
skip( 'HTML::Packer not installed!', $not ) if ( $@ );
plan tests => $not;
minTest( 's1', undef, 'Test without opts.' );
minTest( 's2', { remove_newlines => 1 }, 'Test remove_newlines.' );
minTest( 's3', { remove_comments => 1 }, 'Test remove_comments.' );
minTest( 's4', { remove_comments => 1, remove_newlines => 1 }, 'Test remove_newlines and remove_comments.' );
minTest( 's5', { remove_comments => 1, remove_newlines => 1 }, 'Test _no_compress_ comment.' );
minTest( 's6', { remove_comments => 1, remove_newlines => 1, no_compress_comment => 1 }, 'Test _no_compress_ comment with no_compress_comment option.' );
my $packer = HTML::Packer->init();
my $js_comp_input = $js_input;
my $js_html5_input = $js_input;
$packer->minify( \$js_comp_input, { remove_comments => 1, remove_newlines => 1, do_javascript => 'clean' } );
$packer->minify( \$js_html5_input, { remove_comments => 1, remove_newlines => 1, do_javascript => 'clean', html5 => 1 } );
$packer->minify( \$html_input, { remove_comments => 1, remove_newlines => 1, do_javascript => 'clean', html5 => 1 } );
eval "use JavaScript::Packer $HTML::Packer::REQUIRED_JAVASCRIPT_PACKER;";
if ( $@ ) {
is( $js_comp_input, $js_expected_no_js, 'Test do_javascript. JavaScript::Packer >= ' . $HTML::Packer::REQUIRED_JAVASCRIPT_PACKER . ' not installed.' );
is( $js_html5_input, $js_expected_html5_no_js, 'Test do_javascript 2. JavaScript::Packer >= ' . $HTML::Packer::REQUIRED_JAVASCRIPT_PACKER . ' not installed.' );
is( $html_input, $html_expected_no_js, 'Test do_javascript 3. JavaScript::Packer >= ' . $HTML::Packer::REQUIRED_JAVASCRIPT_PACKER . ' not installed.' );
}
else {
is( $js_comp_input, $js_expected, 'Test do_javascript. JavaScript::Packer installed.' );
is( $js_html5_input, $js_expected_html5, 'Test do_javascript 2. JavaScript::Packer installed.' );
is( $html_input, $html_expected, 'Test do_javascript 3. JavaScript::Packer installed.' );
}
my $css_comp_input = $css_input;
my $css_html5_input = $css_input;
$packer->minify( \$css_comp_input, { remove_comments => 1, remove_newlines => 1, do_stylesheet => 'pretty', html5 => 0 } );
$packer->minify( \$css_html5_input, { remove_comments => 1, remove_newlines => 1, do_stylesheet => 'pretty', html5 => 1 } );
eval "use CSS::Packer $HTML::Packer::REQUIRED_CSS_PACKER;";
if ( $@ ) {
is( $css_comp_input, $css_expected_no_css, 'Test do_stylesheet. CSS::Packer >= ' . $HTML::Packer::REQUIRED_CSS_PACKER . ' not installed.' );
is( $css_html5_input, $css_expected_html5_no_css, 'Test do_stylesheet 2. CSS::Packer >= ' . $HTML::Packer::REQUIRED_CSS_PACKER . ' not installed.' );
}
else {
is( $css_comp_input, $css_expected, 'Test do_stylesheet. CSS::Packer installed.' );
is( $css_html5_input, $css_expected_html5, 'Test do_stylesheet 2. CSS::Packer installed.' );
}
}
sub filesMatch {
my $file1 = shift;
my $file2 = shift;
my $a;
my $b;
while (1) {
$a = getc($file1);
$b = getc($file2);
if (!defined($a) && !defined($b)) { # both files end at same place
return 1;
}
elsif (
!defined($b) || # file2 ends first
!defined($a) || # file1 ends first
$a ne $b
) { # a and b not the same
return 0;
}
}
}
sub minTest {
my $filename = shift;
my $opts = shift || {};
my $message = shift || '';
open(INFILE, 't/html/' . $filename . '.html') or die("couldn't open file");
open(GOTFILE, '>t/html/' . $filename . '-got.html') or die("couldn't open file");
my $html = join( '', );
my $packer = HTML::Packer->init();
$packer->minify( \$html, $opts );
print GOTFILE $html;
close(INFILE);
close(GOTFILE);
open(EXPECTEDFILE, 't/html/' . $filename . '-expected.html') or die("couldn't open file");
open(GOTFILE, 't/html/' . $filename . '-got.html') or die("couldn't open file");
ok(filesMatch(GOTFILE, EXPECTEDFILE), $message );
close(EXPECTEDFILE);
close(GOTFILE);
}
HTML-Packer-2.02/t/html/ 000755 000765 000024 00000000000 12651452011 016117 5 ustar 00leejohnson staff 000000 000000 HTML-Packer-2.02/t/pod.t 000644 000765 000024 00000000350 12534004166 016124 0 ustar 00leejohnson staff 000000 000000 #!perl -T
use strict;
use warnings;
use Test::More;
# Ensure a recent version of Test::Pod
my $min_tp = 1.22;
eval "use Test::Pod $min_tp";
plan skip_all => "Test::Pod $min_tp required for testing POD" if $@;
all_pod_files_ok();
HTML-Packer-2.02/t/html/s1-expected.html 000644 000765 000024 00000000124 12534004166 021130 0 ustar 00leejohnson staff 000000 000000 link
1
link 2