Skip to content
Draft
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
18 changes: 15 additions & 3 deletions scripts/bibSplit.pl
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,20 @@ sub sanitize_text {
my $itemTitle = sanitize_text($obj->{title} // '');
my $title = $itemTitle eq '' ? "title: ''" : "title: |\n $itemTitle\n";

my $urlSource = defined $obj->{url} ? $obj->{url} : '';

print STDERR qq{$key --> "$urlSource" on "$itemTitle".\n};
# test if the URL is accessible
if ($urlSource ne '') {
if (system(qq{curl --output /dev/null --silent --show-error --head --fail --dump-header "$key.hdr" --location --referer "https://interlisp.org/history/bibliography;auto" "$urlSource"}) != 0) {
print STDERR qq{URL is broken or unreachable.\n};
}
else
{
unlink("$key.hdr");
}
}

# Abstracts can be multi-line and contain multiple paragraphs. Place YAML keyword on
# one line and follow it with the abstract indented on subsequent lines.
my $abs = sanitize_text($obj->{abstract} // '');
Expand Down Expand Up @@ -101,8 +115,6 @@ sub sanitize_text {
$itemEditors =~ s/\n$//u; # strip trailing newline
}

my $urlSource = defined $obj->{url} ? $obj->{url} : '';

# Modified date
my $dateModified = defined $obj->{dateModified} ? $obj->{dateModified} : '';

Expand Down Expand Up @@ -165,7 +177,7 @@ sub sanitize_text {
} elsif ($type eq 'entry-encyclopedia') {
$extraFields = "encyclopedia_title: $encyclopediaTitle\n";
} else {
print STDERR "Warning: unhandled type \"$type\" for key \"$key\"\n";
# print STDERR "Warning: unhandled type \"$type\" for key \"$key\"\n";
}

# Todo: Remove writing the json file once we're happy with the markdown files
Expand Down