Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hevea-add-verbatim-linenos
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ def replace_line(match: re.Match[str]) -> str:
with Path(htmlfile).open() as htmlfile_handle:
for line in htmlfile_handle:
line = lineref_re.sub(replace_line, line)
print(line)
print(line, end="")
2 changes: 1 addition & 1 deletion html-update-link-dates
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ sub file_size ( $ )
# 5 to the third most significant digit (since we truncate to two
# significant digits).
my $to_add = "5" . ("0" x (length($size) - 3));
$trunc_size = sprintf("%f", ($size + $to_add) / $divisor);
my $trunc_size = sprintf("%f", ($size + $to_add) / $divisor);
if ($trunc_size =~ m/^([0-9][0-9])([0-9]*)(\.[0-9]*)?$/)
{
$trunc_size = $1 . "0" x length($2);
Expand Down
14 changes: 10 additions & 4 deletions html-update-toc
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ FILELOOP: for my $file (@ARGV)
}
next;
}
if (!open(FILE, $file))
if (!open(FILE, '<', $file))
{
print STDERR "Skipping $file: can't open\n";
next;
Expand Down Expand Up @@ -131,7 +131,13 @@ FILELOOP: for my $file (@ARGV)
if ($line =~ /($contents_start)(.*?)($contents_end)/is)
{
my $oldcontent = $2;
my $newcontent = `$script_dir/html-toc $file`;
open(my $toc_pipe, '-|', "$script_dir/html-toc", $file)
or die "Can't run html-toc: $!";
my $newcontent = do { local $/; <$toc_pipe> };
close($toc_pipe) or die(
$! ? "Error closing pipe: $!"
: "html-toc failed for $file (exit status: $?)"
);
if ($newcontent eq "\n")
{
$newcontent = "";
Expand All @@ -156,9 +162,9 @@ FILELOOP: for my $file (@ARGV)
# "perl -pi.bak -e '\$/ = \"\\n\\n\"; s/($contents_start_quoted)(.*?)($contents_end_quoted)/\$1$newcontent_quoted\$3/s'"
# but that doesn't work: the shell says "word too long".
rename($file, "$file.bak") or die "Can't make backup of $file";
open(OLDFILE, "$file.bak")
open(OLDFILE, '<', "$file.bak")
or die "Can't read backup I just made: $file.bak";
open(FILE, ">$file")
open(FILE, '>', $file)
or die "Can't write $file; old version in $file.bak";
while (defined($line = <OLDFILE>))
{
Expand Down