mirror of
https://codeberg.org/h3xx/simplify_static_dir
synced 2024-08-14 23:57:24 +00:00
Fix squasher stripping repeated newlines in ignored sections
This commit is contained in:
parent
4d4edd5e9d
commit
a26764fd2f
1 changed files with 13 additions and 3 deletions
16
util/squash
16
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;
|
||||
|
|
Loading…
Reference in a new issue