diff options
author | Norbert Preining <norbert@preining.info> | 2023-09-04 03:04:17 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2023-09-04 03:04:17 +0000 |
commit | 6cc1e9947e6e547a181fd0510d399af947c7bbc9 (patch) | |
tree | f10ff1c91dcd60c85ba8e881b24b09911827a28a /biblio/bibtex | |
parent | 59b528f442538943e1d34291a905464d987035ee (diff) |
CTAN sync 202309040304
Diffstat (limited to 'biblio/bibtex')
-rw-r--r-- | biblio/bibtex/utils/bibcop/DEPENDS.txt | 14 | ||||
-rw-r--r-- | biblio/bibtex/utils/bibcop/README.md | 8 | ||||
-rw-r--r-- | biblio/bibtex/utils/bibcop/bibcop.1 | 2 | ||||
-rw-r--r-- | biblio/bibtex/utils/bibcop/bibcop.dtx | 2 | ||||
-rw-r--r-- | biblio/bibtex/utils/bibcop/bibcop.pdf | bin | 347548 -> 347540 bytes | |||
-rwxr-xr-x | biblio/bibtex/utils/bibcop/bibcop.pl | 63 |
6 files changed, 69 insertions, 20 deletions
diff --git a/biblio/bibtex/utils/bibcop/DEPENDS.txt b/biblio/bibtex/utils/bibcop/DEPENDS.txt index 32acfffc04..80be72d900 100644 --- a/biblio/bibtex/utils/bibcop/DEPENDS.txt +++ b/biblio/bibtex/utils/bibcop/DEPENDS.txt @@ -1,2 +1,16 @@ hard iexec hard pgfopts +soft biber +soft biblatex +soft bibtex +soft ffcode +soft href-ul +soft hypdoc +soft l3build +soft libertine +soft microtype +soft newtx +soft pgfopts +soft scheme-basic +soft verbatimcopy +soft xetex
\ No newline at end of file diff --git a/biblio/bibtex/utils/bibcop/README.md b/biblio/bibtex/utils/bibcop/README.md index 350660b169..55101b4e2d 100644 --- a/biblio/bibtex/utils/bibcop/README.md +++ b/biblio/bibtex/utils/bibcop/README.md @@ -23,9 +23,9 @@ and then use in the preamble (if you use [BibTeX](http://www.bibtex.org/), for e \end{document} ``` -Otherwise, you can download [`bibcop.sty`](https://raw.githubusercontent.com/yegor256/bibcop/gh-pages/bibcop/bibcop.sty) and add to your project (together with [`bibcop.pl`](https://raw.githubusercontent.com/yegor256/bibcop/master/bibcop.pl)!). +Otherwise, you can download [`bibcop.sty`](https://raw.githubusercontent.com/yegor256/bibcop/gh-pages/bibcop.sty) and add to your project (together with [`bibcop.pl`](https://raw.githubusercontent.com/yegor256/bibcop/gh-pages/bibcop.pl)!). -You can also download [`bibcop.pl`](https://raw.githubusercontent.com/yegor256/bibcop/master/bibcop.pl) +You can also download [`bibcop.pl`](https://raw.githubusercontent.com/yegor256/bibcop/gh-pages/bibcop.pl) and use it as a command line tool to check your `.bib` files and to auto-fix them (you should have [Perl](https://www.perl.org) installed): @@ -62,4 +62,6 @@ When ready, run this, in order to check that all tests pass: $ perl tests.pl ``` -You should see the `GREAT!` message.
\ No newline at end of file +You should see the `GREAT!` message. + +Copyright (c) 2022-2023 Yegor Bugayenko, MIT License
\ No newline at end of file diff --git a/biblio/bibtex/utils/bibcop/bibcop.1 b/biblio/bibtex/utils/bibcop/bibcop.1 index 63c4e63688..e167fb442c 100644 --- a/biblio/bibtex/utils/bibcop/bibcop.1 +++ b/biblio/bibtex/utils/bibcop/bibcop.1 @@ -1,4 +1,4 @@ -.TH bibcop 1 "2023-06-30" +.TH bibcop 1 "2023-09-03" .SH NAME bibcop \- Style Checker and Fixer of BibTeX Files (.bib) .SH SYNOPSIS diff --git a/biblio/bibtex/utils/bibcop/bibcop.dtx b/biblio/bibtex/utils/bibcop/bibcop.dtx index 11619f4b45..cdd5dddc4c 100644 --- a/biblio/bibtex/utils/bibcop/bibcop.dtx +++ b/biblio/bibtex/utils/bibcop/bibcop.dtx @@ -50,7 +50,7 @@ %<package>\NeedsTeXFormat{LaTeX2e} %<package>\ProvidesPackage{bibcop} %<*package> -[2023-06-30 0.0.14 Style Checker of Bibliography Files] +[2023-09-03 0.0.15 Style Checker of Bibliography Files] %</package> %<*driver> \documentclass{ltxdoc} diff --git a/biblio/bibtex/utils/bibcop/bibcop.pdf b/biblio/bibtex/utils/bibcop/bibcop.pdf Binary files differindex 6228db525d..9620cedd9c 100644 --- a/biblio/bibtex/utils/bibcop/bibcop.pdf +++ b/biblio/bibtex/utils/bibcop/bibcop.pdf diff --git a/biblio/bibtex/utils/bibcop/bibcop.pl b/biblio/bibtex/utils/bibcop/bibcop.pl index 276d435dab..a9b2057895 100755 --- a/biblio/bibtex/utils/bibcop/bibcop.pl +++ b/biblio/bibtex/utils/bibcop/bibcop.pl @@ -21,6 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. +# 2023-09-03 0.0.15 package bibcop; use warnings; @@ -40,6 +41,7 @@ my %blessed = ( 'misc' => ['title', 'author', 'year', 'eprint?', 'archiveprefix?', 'primaryclass?', 'publisher?', 'organization?', 'doi?', 'url?'], ); +# See https://research.arizona.edu/faq/what-do-you-mean-when-you-say-use-title-case-proposalproject-titles 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. @@ -130,9 +132,6 @@ sub check_author { return; } my $author = clean_tex($entry{'author'}); - if (index($author, '{') != -1) { - return; - } my @authors = split(/\s+and\s+/, $author); my $pos = 0; for my $a (@authors) { @@ -140,11 +139,25 @@ sub check_author { if ($a eq 'others') { next; } - if (not $a =~ /^[A-Z][^ .]+( [A-Z][^ .]+)*(,( [A-Z][^ ]+)+)?$/) { - return "The format of @{[as_position($pos)]} 'author' is wrong, use something like 'Knuth, Donald E. and Duane, Bibby'" + if (index($a, ' ') != -1 and index($a, ',') == -1) { + return "The last name should go first, all other names must follow, after a comma in @{[as_position($pos)]} 'author', as in 'Knuth, Donald E.'"; } - if ($author =~ /.*[A-Z]([ ,]|$).*/) { - return "A shortened name must have a tailing dot in @{[as_position($pos)]} 'author', as in 'Knuth, Donald E.'" + my $npos = 0; + for my $name (split(/[ ,]+/, $a)) { + $npos += 1; + if (index($name, '{') != -1) { + next; + } + if ($name =~ /^[A-Z]\.$/) { + next; + } + if ($name =~ /^[A-Z][^.]+$/) { + next + } + if ($name =~ /^[A-Z]$/) { + return "A shortened name must have a tailing dot in @{[as_position($pos)]} 'author', as in 'Knuth, Donald E.'"; + } + return "In @{[as_position($pos)]} 'author' @{[as_position($npos)]} name looks suspicious ($name), use something like 'Knuth, Donald E. and Duane, Bibby'"; } } } @@ -386,7 +399,7 @@ sub check_doi { my (%entry) = @_; if (exists $entry{'doi'}) { my $doi = $entry{'doi'}; - if (not $doi =~ /^[0-9a-zA-Z.]+\/[0-9a-zA-Z._\-)(]+$/) { + if (not $doi =~ /^[0-9a-zA-Z.]+\/[0-9a-zA-Z._\-)(><:;]+$/) { return "The format of the 'doi' is wrong" } } @@ -553,9 +566,26 @@ sub fix_pages { if ($value =~ /^[1-9][0-9]*$/) { return $value; } - my ($left, $right) = split(/---|--|-|—|\s/, $value); + my ($left, $right) = split(/---|--|-|–|—|\s/, $value); + if ($left eq '') { + $left = $right; + } + if ($right eq '') { + $right = $left; + } $left =~ s/^0+//g; $right =~ s/^0+//g; + if ($left !~ /^[0-9]*$/ or $right !~ /^[0-9]*$/) { + return $value; + } + if ($left + 0 gt $right + 0) { + my $tmp = $left; + $left = $right; + $right = $tmp; + } + if ($left eq $right) { + return $left; + } return $left . '--' . $right; } @@ -604,8 +634,10 @@ sub entries { if ($char eq ' ') { # ignore the white space } elsif ($char eq '%' and not($s eq 'quote')) { - $interrupted = $s; - $s = 'comment'; + if ($pos eq 0 or substr($bib, $pos - 1, 1) ne '\\') { + $interrupted = $s; + $s = 'comment'; + } } elsif ($char eq "\n") { # ignore the EOL $lineno = $lineno + 1; @@ -620,7 +652,7 @@ sub entries { $s = 'start'; $acc = ''; } else { - warning("Each BibTeX entry must start with '\@', what is '$char'?"); + warning("Each BibTeX entry must start with '\@', what is '$char' at line no.$lineno?"); last; } } elsif ($char =~ /[a-zA-Z]/ and $s eq 'start') { @@ -642,7 +674,7 @@ sub entries { } elsif ($char eq '=' and $s eq 'tag') { my $t = lc($acc); if (exists $entry{$t}) { - warning("The tag '$t' is seen more than once"); + warning("The tag '$t' is seen more than once at line no.$lineno"); } $tag = $t; $s = 'value'; @@ -829,9 +861,9 @@ 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.14'); + info('0.0.15 2023-09-03'); } else { - my ($file) = grep { not($_ =~ /^--.*$/) } @ARGV; + my ($file) = grep { not($_ =~ /^-.*$/) } @ARGV; if (not $file) { error('File name must be specified'); } @@ -903,4 +935,5 @@ if (@ARGV+0 eq 0 or exists $args{'--help'} or exists $args{'-?'}) { } } +# In order to finish it with success: 1; |