diff --git a/util/squash b/util/squash index f46e2f8..a015533 100755 --- a/util/squash +++ b/util/squash @@ -20,6 +20,7 @@ for my $arg (@ARGV) { my $in_pod = 0; my $in_section = ''; my $ignore_lines = 0; + my $empty_lines = 0; while (<$fh>) { if (/#.*:squash-ignore-start:$/) { $in_section = 'ignore'; @@ -34,10 +35,22 @@ for my $arg (@ARGV) { } if ($in_section eq 'ignore') { + $empty_lines = 0 unless /^$/; $code .= $_; next; } + # Remove repeated newlines between paragraphs + # (Provided of course we're not in an 'ignore' section) + if (/^$/) { + ++$empty_lines; + if ($empty_lines > 1) { + next; + } + } else { + $empty_lines = 0; + } + if (/#.*:squash-remove-start:$/) { $in_section = 'remove'; next; @@ -74,9 +87,6 @@ for my $arg (@ARGV) { close $fh; } -# Remove repeated newlines between paragraphs -$code =~ s/\n\n+/\n\n/gs; - print $code; exit 0;