From 13348a3c45768d4d39f7c870b0f2dfb3bbeb2b0f Mon Sep 17 00:00:00 2001 From: Hutzdog Date: Tue, 21 Mar 2023 12:28:49 -0700 Subject: [PATCH] Hopefully reduce needless whitespace --- cap2site.pl | 8 +++++--- t/hello_exp.html | 2 ++ t/hello_standalone_exp.html | 11 +++++++++++ t/script.pl | 30 ++++++++++-------------------- 4 files changed, 28 insertions(+), 23 deletions(-) create mode 100644 t/hello_exp.html create mode 100644 t/hello_standalone_exp.html diff --git a/cap2site.pl b/cap2site.pl index 6598449..329126d 100755 --- a/cap2site.pl +++ b/cap2site.pl @@ -199,10 +199,12 @@ sub parse($$$) { print '
', escape(trimLeft(substr $line, 1)), '
', "\n"; } + elsif ($line eq "") { + print '
', "\n"; + } + else { - print '

'; - print (length($line) == 0 ? '
' : escape $line); - print '

', "\n"; + print '

', escape($line), '

', "\n"; } } diff --git a/t/hello_exp.html b/t/hello_exp.html new file mode 100644 index 0000000..f24c61f --- /dev/null +++ b/t/hello_exp.html @@ -0,0 +1,2 @@ +

Hello, world!

+

Lorem ipsum dolor sit amet

diff --git a/t/hello_standalone_exp.html b/t/hello_standalone_exp.html new file mode 100644 index 0000000..eb71546 --- /dev/null +++ b/t/hello_standalone_exp.html @@ -0,0 +1,11 @@ + + + + + + + +

Hello, world!

+

Lorem ipsum dolor sit amet

+ + diff --git a/t/script.pl b/t/script.pl index c2b42fd..1685c32 100755 --- a/t/script.pl +++ b/t/script.pl @@ -7,27 +7,17 @@ sub test($$$) { my ($cmd,$file,$expected) = @_; my $res = readpipe($cmd . " < t/" . $file); - $res eq $expected or die "FAIL: $cmd\nEXPECTED:\n$expected\nACTUAL:\n$res"; + my $exp = do { + local $/ = undef; + open my $fh, "<", "t/" . $expected + or die "error opening file: $!"; + <$fh> + }; + + $res eq $exp or die "FAIL: $cmd\nEXPECTED:\n$exp\nACTUAL:\n$res"; } -# TODO: testing format -test("./cap2site.pod", "hello.gmi", <<'EOF'); -

Hello, world!

-

Lorem ipsum dolor sit amet

-EOF - -test("./cap2site.pod -s", "hello.gmi", <<'EOF'); - - - - - - - -

Hello, world!

-

Lorem ipsum dolor sit amet

- - -EOF +test("./cap2site.pod", "hello.gmi", "hello_exp.html"); +test("./cap2site.pod -s", "hello.gmi", "hello_standalone_exp.html"); say "DONE!";