From 8c77c4248f99aff397021a2dc16cfa2fa4c14257 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Tue, 16 May 2023 20:20:41 +0000 Subject: bibcop (16may23) git-svn-id: svn://tug.org/texlive/trunk@67131 c570f23f-e606-0410-a88d-b1316a301751 --- .../texk/texlive/linked_scripts/bibcop/bibcop.pl | 101 ++++++++++++++++++++- Master/texmf-dist/doc/bibtex/bibcop/bibcop.pdf | Bin 343290 -> 343404 bytes Master/texmf-dist/doc/man/man1/bibcop.1 | 2 +- Master/texmf-dist/doc/man/man1/bibcop.man1.pdf | Bin 13273 -> 13270 bytes Master/texmf-dist/scripts/bibcop/bibcop.pl | 101 ++++++++++++++++++++- Master/texmf-dist/source/bibtex/bibcop/bibcop.dtx | 2 +- Master/texmf-dist/tex/latex/bibcop/bibcop.sty | 2 +- Master/tlpkg/bin/tlpkg-ctan-check | 1 + Master/tlpkg/libexec/ctan2tds | 1 + 9 files changed, 199 insertions(+), 11 deletions(-) diff --git a/Build/source/texk/texlive/linked_scripts/bibcop/bibcop.pl b/Build/source/texk/texlive/linked_scripts/bibcop/bibcop.pl index eb337fc365e..cfe8e3ac476 100755 --- a/Build/source/texk/texlive/linked_scripts/bibcop/bibcop.pl +++ b/Build/source/texk/texlive/linked_scripts/bibcop/bibcop.pl @@ -40,6 +40,8 @@ my %blessed = ( 'misc' => ['title', 'author', 'year', 'eprint?', 'archiveprefix?', 'primaryclass?', 'publisher?', 'organization?', 'doi?', 'url?'], ); +my %minors = map { $_ => 1 } qw/in of at to by the a an and or as if up via yet nor but off on for into/; + # Check the presence of mandatory tags. sub check_mandatory_tags { my (%entry) = @_; @@ -71,7 +73,6 @@ sub check_mandatory_tags { sub check_capitalization { my (%entry) = @_; my %tags = map { $_ => 1 } qw/title booktitle journal publisher organization/; - my %minors = map { $_ => 1 } qw/in of at to by the a an and or as if up via yet nor but off on for into/; foreach my $tag (keys %entry) { if (not exists $tags{$tag}) { next; @@ -241,13 +242,13 @@ sub check_typography { } } foreach my $s (@space_before) { - if ($value =~ /^.*[^\s]\Q$s\E.*$/) { + if ($value =~ /^.*[^\{\s]\Q$s\E.*$/) { return "In the '$tag', put a space before the $symbols{$s}" } } foreach my $s (@space_after) { my $p = join('', @no_space_before); - if ($value =~ /^.*\Q$s\E[^\s\Q$p\E].*$/) { + if ($value =~ /^.*\Q$s\E[^\}\s\Q$p\E].*$/) { return "In the '$tag', put a space after the $symbols{$s}" } } @@ -435,6 +436,92 @@ sub process_entry { return @errors; } +sub fix_author { + my ($value) = @_; + my @authors = split(/\s?and\s?/, $value); + foreach my $author (@authors) { + $author =~ s/^\s+|\s+$//g; + $author =~ s/ ([A-Z])($| )/ $1.$2/g; + } + return join(' and ', @authors); +} + +sub fix_number { + my ($value) = @_; + $value =~ s/^0+//g; + return $value; +} + +sub fix_capitalization { + my ($value) = @_; + my @words = split(/\s+/, $value); + my $pos = 0; + foreach my $word (@words) { + $pos += 1; + if (not $word =~ /^[A-Za-z]/) { + next; + } + if (exists $minors{$word}) { + next; + } + if (exists $minors{lc($word)} and $pos gt 1) { + $word = lc($word); + next; + } + if ($word =~ /^[a-z].*/) { + $word =~ s/^([a-z])/\U$1/g; + } + if (index($word, '-') != -1) { + $word =~ s/-([a-z])/-\U$1/g; + } + } + return join(' ', @words); +} + +sub fix_title { + my ($value) = @_; + $value = fix_capitalization($value); + return $value; +} + +sub fix_pages { + my ($value) = @_; + if ($value =~ /^[1-9][0-9]*$/) { + return $value; + } + my ($left, $right) = split(/---|--|-|—|\s/, $value); + $left =~ s/^0+//g; + $right =~ s/^0+//g; + return $left . '--' . $right; +} + +sub fix_booktitle { + my ($value) = @_; + $value = fix_capitalization($value); + if (index($value, 'Proceedings ') != 0) { + $value = 'Proceedings of the ' . $value; + } + return $value; +} + +sub fix_journal { + my ($value) = @_; + $value = fix_capitalization($value); + return $value; +} + +sub fix_publisher { + my ($value) = @_; + $value = fix_capitalization($value); + return $value; +} + +sub fix_organization { + my ($value) = @_; + $value = fix_capitalization($value); + return $value; +} + # Parse the incoming .bib file and return an array # of hash-maps, where each one is a bibentry. sub entries { @@ -640,7 +727,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.9'); + info('0.0.10'); } else { my ($file) = grep { not($_ =~ /^--.*$/) } @ARGV; if (not $file) { @@ -667,6 +754,12 @@ if (@ARGV+0 eq 0 or exists $args{'--help'} or exists $args{'-?'}) { next; } my $value = clean_tex($entry{$tag}); + my $fixer = "fix_$tag"; + my $fixed = $value; + if (defined &{$fixer}) { + no strict 'refs'; + $value = $fixer->($value); + } if ($tag =~ /title|booktitle|journal/) { $value = '{' . $value . '}'; } diff --git a/Master/texmf-dist/doc/bibtex/bibcop/bibcop.pdf b/Master/texmf-dist/doc/bibtex/bibcop/bibcop.pdf index 09a4e1e5d00..be16c4e36da 100644 Binary files a/Master/texmf-dist/doc/bibtex/bibcop/bibcop.pdf and b/Master/texmf-dist/doc/bibtex/bibcop/bibcop.pdf differ diff --git a/Master/texmf-dist/doc/man/man1/bibcop.1 b/Master/texmf-dist/doc/man/man1/bibcop.1 index 19bb874117e..93e3ccd28ea 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 "2023-02-13" +.TH bibcop 1 "2023-05-16" .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 a41f85ad2fc..04694d02be6 100644 Binary files a/Master/texmf-dist/doc/man/man1/bibcop.man1.pdf and b/Master/texmf-dist/doc/man/man1/bibcop.man1.pdf differ diff --git a/Master/texmf-dist/scripts/bibcop/bibcop.pl b/Master/texmf-dist/scripts/bibcop/bibcop.pl index eb337fc365e..cfe8e3ac476 100755 --- a/Master/texmf-dist/scripts/bibcop/bibcop.pl +++ b/Master/texmf-dist/scripts/bibcop/bibcop.pl @@ -40,6 +40,8 @@ my %blessed = ( 'misc' => ['title', 'author', 'year', 'eprint?', 'archiveprefix?', 'primaryclass?', 'publisher?', 'organization?', 'doi?', 'url?'], ); +my %minors = map { $_ => 1 } qw/in of at to by the a an and or as if up via yet nor but off on for into/; + # Check the presence of mandatory tags. sub check_mandatory_tags { my (%entry) = @_; @@ -71,7 +73,6 @@ sub check_mandatory_tags { sub check_capitalization { my (%entry) = @_; my %tags = map { $_ => 1 } qw/title booktitle journal publisher organization/; - my %minors = map { $_ => 1 } qw/in of at to by the a an and or as if up via yet nor but off on for into/; foreach my $tag (keys %entry) { if (not exists $tags{$tag}) { next; @@ -241,13 +242,13 @@ sub check_typography { } } foreach my $s (@space_before) { - if ($value =~ /^.*[^\s]\Q$s\E.*$/) { + if ($value =~ /^.*[^\{\s]\Q$s\E.*$/) { return "In the '$tag', put a space before the $symbols{$s}" } } foreach my $s (@space_after) { my $p = join('', @no_space_before); - if ($value =~ /^.*\Q$s\E[^\s\Q$p\E].*$/) { + if ($value =~ /^.*\Q$s\E[^\}\s\Q$p\E].*$/) { return "In the '$tag', put a space after the $symbols{$s}" } } @@ -435,6 +436,92 @@ sub process_entry { return @errors; } +sub fix_author { + my ($value) = @_; + my @authors = split(/\s?and\s?/, $value); + foreach my $author (@authors) { + $author =~ s/^\s+|\s+$//g; + $author =~ s/ ([A-Z])($| )/ $1.$2/g; + } + return join(' and ', @authors); +} + +sub fix_number { + my ($value) = @_; + $value =~ s/^0+//g; + return $value; +} + +sub fix_capitalization { + my ($value) = @_; + my @words = split(/\s+/, $value); + my $pos = 0; + foreach my $word (@words) { + $pos += 1; + if (not $word =~ /^[A-Za-z]/) { + next; + } + if (exists $minors{$word}) { + next; + } + if (exists $minors{lc($word)} and $pos gt 1) { + $word = lc($word); + next; + } + if ($word =~ /^[a-z].*/) { + $word =~ s/^([a-z])/\U$1/g; + } + if (index($word, '-') != -1) { + $word =~ s/-([a-z])/-\U$1/g; + } + } + return join(' ', @words); +} + +sub fix_title { + my ($value) = @_; + $value = fix_capitalization($value); + return $value; +} + +sub fix_pages { + my ($value) = @_; + if ($value =~ /^[1-9][0-9]*$/) { + return $value; + } + my ($left, $right) = split(/---|--|-|—|\s/, $value); + $left =~ s/^0+//g; + $right =~ s/^0+//g; + return $left . '--' . $right; +} + +sub fix_booktitle { + my ($value) = @_; + $value = fix_capitalization($value); + if (index($value, 'Proceedings ') != 0) { + $value = 'Proceedings of the ' . $value; + } + return $value; +} + +sub fix_journal { + my ($value) = @_; + $value = fix_capitalization($value); + return $value; +} + +sub fix_publisher { + my ($value) = @_; + $value = fix_capitalization($value); + return $value; +} + +sub fix_organization { + my ($value) = @_; + $value = fix_capitalization($value); + return $value; +} + # Parse the incoming .bib file and return an array # of hash-maps, where each one is a bibentry. sub entries { @@ -640,7 +727,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.9'); + info('0.0.10'); } else { my ($file) = grep { not($_ =~ /^--.*$/) } @ARGV; if (not $file) { @@ -667,6 +754,12 @@ if (@ARGV+0 eq 0 or exists $args{'--help'} or exists $args{'-?'}) { next; } my $value = clean_tex($entry{$tag}); + my $fixer = "fix_$tag"; + my $fixed = $value; + if (defined &{$fixer}) { + no strict 'refs'; + $value = $fixer->($value); + } if ($tag =~ /title|booktitle|journal/) { $value = '{' . $value . '}'; } diff --git a/Master/texmf-dist/source/bibtex/bibcop/bibcop.dtx b/Master/texmf-dist/source/bibtex/bibcop/bibcop.dtx index e688e2379e4..a1a5a08c99f 100644 --- a/Master/texmf-dist/source/bibtex/bibcop/bibcop.dtx +++ b/Master/texmf-dist/source/bibtex/bibcop/bibcop.dtx @@ -50,7 +50,7 @@ %\NeedsTeXFormat{LaTeX2e} %\ProvidesPackage{bibcop} %<*package> -[2023-02-13 0.0.9 Style Checker of Bibliography Files] +[2023-05-16 0.0.10 Style Checker of Bibliography Files] % %<*driver> \documentclass{ltxdoc} diff --git a/Master/texmf-dist/tex/latex/bibcop/bibcop.sty b/Master/texmf-dist/tex/latex/bibcop/bibcop.sty index d3c5a1287f3..ccc02e1854c 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} -[2023-02-13 0.0.9 Style Checker of Bibliography Files] +[2023-05-16 0.0.10 Style Checker of Bibliography Files] diff --git a/Master/tlpkg/bin/tlpkg-ctan-check b/Master/tlpkg/bin/tlpkg-ctan-check index 321d5aec51f..e4c6652c1db 100755 --- a/Master/tlpkg/bin/tlpkg-ctan-check +++ b/Master/tlpkg/bin/tlpkg-ctan-check @@ -921,6 +921,7 @@ my @TLP_working = qw( # these packages we do not expect to check. Once this list is complete, # we can start working on tlmgr list | grep shortdesc. my @TLP_no_check = ( + "adobeornaments", # nonfree "afm2pl", # not on ctan "aleph", # binary "asymptote", # binary diff --git a/Master/tlpkg/libexec/ctan2tds b/Master/tlpkg/libexec/ctan2tds index e809e44cb1a..1109f1375b1 100755 --- a/Master/tlpkg/libexec/ctan2tds +++ b/Master/tlpkg/libexec/ctan2tds @@ -89,6 +89,7 @@ chomp (my $ctan_root = `tlpkginfo --ctan-root`); 'acrotex-js', "die 'skipping, requires adobe'", 'adobe-euro', "die 'skipping, support for nonfree fonts'", 'adobecaslon', "die 'skipping, support for nonfree fonts'", + 'adobeornaments', "die 'skipping, support for nonfree fonts'", 'adrlist', "die 'skipping, noinfo license'", 'ae', "&MAKEae", 'aeb-minitoc', "die 'skipping, per author (dps) request'", -- cgit v1.2.3