Hopefully reduce needless whitespace

This commit is contained in:
Hutzdog 2023-03-21 12:28:49 -07:00
parent 29d4eb5b8d
commit 13348a3c45
4 changed files with 28 additions and 23 deletions

View File

@ -199,10 +199,12 @@ sub parse($$$) {
print '<blockquote>', escape(trimLeft(substr $line, 1)), '</blockquote>', "\n";
}
elsif ($line eq "") {
print '<br/>', "\n";
}
else {
print '<p>';
print (length($line) == 0 ? '<br/>' : escape $line);
print '</p>', "\n";
print '<p>', escape($line), '</p>', "\n";
}
}

2
t/hello_exp.html Normal file
View File

@ -0,0 +1,2 @@
<h1>Hello, world!</h1>
<p>Lorem ipsum dolor sit amet</p>

View File

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<link rel="stylesheet" href="style.css"></link>
</head>
<body>
<h1>Hello, world!</h1>
<p>Lorem ipsum dolor sit amet</p>
</body>
</html>

View File

@ -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');
<h1>Hello, world!</h1>
<p>Lorem ipsum dolor sit amet</p>
EOF
test("./cap2site.pod -s", "hello.gmi", <<'EOF');
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<link rel="stylesheet" href="style.css"></link>
</head>
<body>
<h1>Hello, world!</h1>
<p>Lorem ipsum dolor sit amet</p>
</body>
</html>
EOF
test("./cap2site.pod", "hello.gmi", "hello_exp.html");
test("./cap2site.pod -s", "hello.gmi", "hello_standalone_exp.html");
say "DONE!";