summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2024-03-15 21:22:49 +0000
committerKarl Berry <karl@freefriends.org>2024-03-15 21:22:49 +0000
commit064a94cc8dba05ed26f50bffac6955b1e71ed6f3 (patch)
tree921e8ead54e5f68a043f2f2b5620bcb91e8cf541 /Master
parent7ad7136887f898991bb6705c6caee204690a8d35 (diff)
bibcop (15mar24)
git-svn-id: svn://tug.org/texlive/trunk@70645 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r--Master/texmf-dist/doc/bibtex/bibcop/bibcop.pdfbin347804 -> 347801 bytes
-rw-r--r--Master/texmf-dist/doc/man/man1/bibcop.12
-rw-r--r--Master/texmf-dist/doc/man/man1/bibcop.man1.pdfbin13253 -> 13427 bytes
-rwxr-xr-xMaster/texmf-dist/scripts/bibcop/bibcop.pl71
-rw-r--r--Master/texmf-dist/source/bibtex/bibcop/bibcop.dtx2
-rw-r--r--Master/texmf-dist/tex/latex/bibcop/bibcop.sty2
6 files changed, 61 insertions, 16 deletions
diff --git a/Master/texmf-dist/doc/bibtex/bibcop/bibcop.pdf b/Master/texmf-dist/doc/bibtex/bibcop/bibcop.pdf
index 71816101591..57e80dcc822 100644
--- a/Master/texmf-dist/doc/bibtex/bibcop/bibcop.pdf
+++ b/Master/texmf-dist/doc/bibtex/bibcop/bibcop.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/man/man1/bibcop.1 b/Master/texmf-dist/doc/man/man1/bibcop.1
index 725f82cfce9..8e8c5cfc0d4 100644
--- a/Master/texmf-dist/doc/man/man1/bibcop.1
+++ b/Master/texmf-dist/doc/man/man1/bibcop.1
@@ -1,4 +1,4 @@
-.TH bibcop 1 "2024-01-17"
+.TH bibcop 1 "2024-03-15"
.SH NAME
bibcop \- Style Checker and Fixer of BibTeX Files (.bib)
.SH SYNOPSIS
diff --git a/Master/texmf-dist/doc/man/man1/bibcop.man1.pdf b/Master/texmf-dist/doc/man/man1/bibcop.man1.pdf
index 3f8a8719f6d..2f644b87b30 100644
--- a/Master/texmf-dist/doc/man/man1/bibcop.man1.pdf
+++ b/Master/texmf-dist/doc/man/man1/bibcop.man1.pdf
Binary files differ
diff --git a/Master/texmf-dist/scripts/bibcop/bibcop.pl b/Master/texmf-dist/scripts/bibcop/bibcop.pl
index 89d101eccf3..e35e9849621 100755
--- a/Master/texmf-dist/scripts/bibcop/bibcop.pl
+++ b/Master/texmf-dist/scripts/bibcop/bibcop.pl
@@ -21,12 +21,13 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
-# 2024-01-17 0.0.19
+# 2024-03-15 0.0.20
package bibcop;
use warnings;
use strict;
use File::Basename;
+use Time::Piece;
# Hash of incoming command line arguments.
my %args = map { $_ => 1 } @ARGV;
@@ -36,10 +37,10 @@ my %args = map { $_ => 1 } @ARGV;
# Only these tags are allowed and only these types of entries.
my %blessed = (
- 'article' => ['doi', 'year', 'title', 'author', 'journal', 'volume', 'number', 'publisher?', 'pages?'],
- 'inproceedings' => ['doi', 'booktitle', 'title', 'author', 'year', 'pages?', 'organization?', 'volume?'],
+ 'article' => ['doi', 'year', 'title', 'author', 'journal', 'volume', 'number', 'month?', 'publisher?', 'pages?'],
+ 'inproceedings' => ['doi', 'booktitle', 'title', 'author', 'year', 'pages?', 'month?', 'organization?', 'volume?'],
'book' => ['title', 'author', 'year', 'publisher', 'doi?'],
- 'misc' => ['title', 'author', 'year', 'eprint?', 'archiveprefix?', 'primaryclass?', 'publisher?', 'organization?', 'doi?', 'url?'],
+ 'misc' => ['title', 'author', 'year', 'eprint?', 'archiveprefix?', 'primaryclass?', 'month?', 'publisher?', 'organization?', 'doi?', 'howpublished?', 'note?'],
);
# See https://research.arizona.edu/faq/what-do-you-mean-when-you-say-use-title-case-proposalproject-titles
@@ -235,7 +236,7 @@ sub check_org_in_booktitle {
return;
}
my (%entry) = @_;
- my @orgs = ( 'ACM', 'IEEE' );
+ my @orgs = qw/ACM IEEE/;
if (exists($entry{'booktitle'})) {
my $title = $entry{'booktitle'};
foreach my $o (@orgs) {
@@ -428,7 +429,7 @@ sub check_month {
my (%entry) = @_;
if (exists $entry{'month'}) {
my $month = $entry{'month'};
- if (not $month =~ /^[1-9]|10|11|12$/) {
+ if (not $month =~ /^[1-9]|10|11|12|jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec$/) {
return "The format of the 'month' is wrong"
}
}
@@ -530,14 +531,26 @@ sub entry_fix {
my $tags = $blessed{$type};
my %allowed = map { $_ => 1 } @$tags;
my @lines;
+ if (exists $entry{'booktitle'} and $entry{':type'} eq 'article') {
+ $entry{'journal'} = $entry{'booktitle'};
+ }
+ if (exists $entry{'journal'} and $entry{':type'} eq 'inproceedings') {
+ $entry{'booktitle'} = $entry{'journal'};
+ }
foreach my $tag (keys %entry) {
if ($tag =~ /^:/) {
next;
}
+ my $value = clean_tex($entry{$tag});
+ if ($tag eq 'url') {
+ my $today = localtime->strftime('%d-%m-%Y');
+ push(@lines, " howpublished = {\\url{$value}},");
+ push(@lines, " note = {[Online; accessed $today]},");
+ next;
+ }
if (not exists $allowed{$tag} and not exists $allowed{$tag . '?'}) {
next;
}
- my $value = clean_tex($entry{$tag});
my $fixer = "fix_$tag";
my $fixed = $value;
if (defined &{$fixer}) {
@@ -562,10 +575,22 @@ sub entry_fix {
sub fix_author {
my ($value) = @_;
+ $value =~ s/\s{2,}/ /g;
my @authors = split(/\s+and\s+/, $value);
foreach my $author (@authors) {
$author =~ s/^\s+|\s+$//g;
+ if (index($author, '{') != -1 or index($author, '}') != -1) {
+ next;
+ }
$author =~ s/ ([A-Z])($| )/ $1.$2/g;
+ if (index($author, ',') eq -1) {
+ my @words = split(/\s+/, $author);
+ my $total = @words+0;
+ if ($total gt 1) {
+ $author = $words[$total - 1] . ', ' . join(' ', @words[0 .. $total - 2]);
+ }
+ }
+ $author =~ s/^\s+|\s+$//g;
}
return join(' and ', @authors);
}
@@ -585,11 +610,9 @@ sub fix_capitalization {
if (not $word =~ /^[A-Za-z]/) {
next;
}
- if (exists $minors{$word}) {
- next;
- }
- if (exists $minors{lc($word)} and $pos gt 1) {
- $word = lc($word);
+ my $lc = lc($word);
+ if (exists $minors{$lc} and $pos gt 1 and not $words[$pos - 2] =~ /:$/) {
+ $word = $lc;
next;
}
if ($word =~ /^[a-z].*/) {
@@ -647,6 +670,11 @@ sub fix_booktitle {
if (index($value, 'Proceedings ') != 0) {
$value = 'Proceedings of the ' . $value;
}
+ $value =~ s/ (19|20)[0-9]{2} / /g;
+ my @orgs = qw/ACM IEEE ACM\/IEEE IEEE\/ACM/;
+ foreach my $org (@orgs) {
+ $value =~ s/ \Q$org\E / /g;
+ }
return $value;
}
@@ -656,15 +684,26 @@ sub fix_journal {
return $value;
}
+sub fix_org_name {
+ my ($value) = @_;
+ my @orgs = qw/ACM IEEE/;
+ foreach my $org (@orgs) {
+ $value =~ s/^\Q$org\E($|[^A-Z0-9a-z].*$)/$org/g;
+ }
+ return $value;
+}
+
sub fix_publisher {
my ($value) = @_;
$value = fix_capitalization($value);
+ $value = fix_org_name($value);
return $value;
}
sub fix_organization {
my ($value) = @_;
$value = fix_capitalization($value);
+ $value = fix_org_name($value);
return $value;
}
@@ -919,7 +958,7 @@ if (@ARGV+0 eq 0 or exists $args{'--help'} or exists $args{'-?'}) {
" --latex Report errors in LaTeX format using \\PackageWarningNoLine command\n\n" .
"If any issues, report to GitHub: https://github.com/yegor256/bibcop");
} elsif (exists $args{'--version'} or exists $args{'-v'}) {
- info('0.0.19 2024-01-17');
+ info('0.0.20 2024-03-15');
} else {
my ($file) = grep { not($_ =~ /^-.*$/) } @ARGV;
if (not $file) {
@@ -930,9 +969,15 @@ if (@ARGV+0 eq 0 or exists $args{'--help'} or exists $args{'-?'}) {
my @entries = entries($bib);
if (exists $args{'--fix'}) {
my $fixed = '';
+ my %seen;
for my $i (0..(@entries+0 - 1)) {
my %entry = %{ $entries[$i] };
+ my $name = $entry{':name'};
+ if (exists $seen{$name}) {
+ next;
+ }
$fixed = $fixed . entry_fix(%entry);
+ $seen{$name} = 1;
}
if (exists $args{'-i'} or exists $args{'--in-place'}) {
open(my $out, '>', $file) or error('Cannot open file for writing: ' . $file);
diff --git a/Master/texmf-dist/source/bibtex/bibcop/bibcop.dtx b/Master/texmf-dist/source/bibtex/bibcop/bibcop.dtx
index 00a162fb819..e1ab46aa8e0 100644
--- a/Master/texmf-dist/source/bibtex/bibcop/bibcop.dtx
+++ b/Master/texmf-dist/source/bibtex/bibcop/bibcop.dtx
@@ -50,7 +50,7 @@
%<package>\NeedsTeXFormat{LaTeX2e}
%<package>\ProvidesPackage{bibcop}
%<*package>
-[2024-01-17 0.0.19 Style Checker of Bibliography Files]
+[2024-03-15 0.0.20 Style Checker of Bibliography Files]
%</package>
%<*driver>
\documentclass{ltxdoc}
diff --git a/Master/texmf-dist/tex/latex/bibcop/bibcop.sty b/Master/texmf-dist/tex/latex/bibcop/bibcop.sty
index db8b9999914..83d31e21c51 100644
--- a/Master/texmf-dist/tex/latex/bibcop/bibcop.sty
+++ b/Master/texmf-dist/tex/latex/bibcop/bibcop.sty
@@ -31,7 +31,7 @@
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{bibcop}
-[2024-01-17 0.0.19 Style Checker of Bibliography Files]
+[2024-03-15 0.0.20 Style Checker of Bibliography Files]