summaryrefslogtreecommitdiff
path: root/biblio/bibtex
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2023-05-19 03:01:08 +0000
committerNorbert Preining <norbert@preining.info>2023-05-19 03:01:08 +0000
commitdd54bf2a9c9e985917ceb5ced412213cd44eaeae (patch)
tree0d0a94b7cad225ba7570c9ae16082392e2c41a2b /biblio/bibtex
parentb2f81626104e48abe103ae135fb0d538bb2de3cd (diff)
CTAN sync 202305190301
Diffstat (limited to 'biblio/bibtex')
-rw-r--r--biblio/bibtex/utils/bibcop/README.md2
-rw-r--r--biblio/bibtex/utils/bibcop/bibcop.12
-rw-r--r--biblio/bibtex/utils/bibcop/bibcop.dtx60
-rw-r--r--biblio/bibtex/utils/bibcop/bibcop.pdfbin343404 -> 347218 bytes
-rwxr-xr-xbiblio/bibtex/utils/bibcop/bibcop.pl68
5 files changed, 106 insertions, 26 deletions
diff --git a/biblio/bibtex/utils/bibcop/README.md b/biblio/bibtex/utils/bibcop/README.md
index cda41a8ddd..350660b169 100644
--- a/biblio/bibtex/utils/bibcop/README.md
+++ b/biblio/bibtex/utils/bibcop/README.md
@@ -12,7 +12,7 @@ they do _almost_ the same but from the command line.
First, [install it](https://en.wikibooks.org/wiki/LaTeX/Installing_Extra_Packages)
from [CTAN](https://ctan.org/pkg/bibcop)
-and then use in the preamble (if you use BibTeX, for example):
+and then use in the preamble (if you use [BibTeX](http://www.bibtex.org/), for example):
```tex
\documentclass{article}
diff --git a/biblio/bibtex/utils/bibcop/bibcop.1 b/biblio/bibtex/utils/bibcop/bibcop.1
index 93e3ccd28e..85a0e54099 100644
--- a/biblio/bibtex/utils/bibcop/bibcop.1
+++ b/biblio/bibtex/utils/bibcop/bibcop.1
@@ -1,4 +1,4 @@
-.TH bibcop 1 "2023-05-16"
+.TH bibcop 1 "2023-05-18"
.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 a1a5a08c99..d29137b21b 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-05-16 0.0.10 Style Checker of Bibliography Files]
+[2023-05-18 0.0.11 Style Checker of Bibliography Files]
%</package>
%<*driver>
\documentclass{ltxdoc}
@@ -149,6 +149,27 @@
%</verb>
%\fi
+% \DescribeMacro{no*}
+% It's possible to suppress certain rules, by using one of the |no*| package options:
+%\iffalse
+%<*verb>
+%\fi
+\begin{verbatim}
+\usepackage[nodoi,nowraps]{bibcop}
+\end{verbatim}
+%\iffalse
+%</verb>
+%\fi
+% The following options are available:
+% \begin{itemize}\setlength\itemsep{0pt}
+% \item |nocaps| allows arbitrary capitalization in titles;
+% \item |nowraps| allows titles to have no double curly braces;
+% \item |nodoi| allows the absence of the |doi| tag in all entries;
+% \item |noinproc| allows the |booktitle| tag in |@inproceedings| entries to not start with ``Proceedings of the'';
+% \item |noorg| allows mentioning of ACM/IEEE in the |booktitle| tag;
+% \item |notags| allows any tags and allow to miss important tags.
+% \end{itemize}
+
% \section{The Rules}
% This is a more or less complete list of rules enforced on a |.bib| file:
@@ -197,6 +218,7 @@ title = {Structured Programming {with} Go {To} Statements}
%\iffalse
%</verb>
%\fi
+% This rule may be disabled by the |nocaps| package option.
% \DescribeMacro{author}
% The |author| must contain a list of authors separated by ``|and|''. Each author
@@ -354,6 +376,7 @@ booktitle = {{Proceedings of the International
%\iffalse
%</verb>
%\fi
+% This rule may be disabled by the |noinproc| package option.
% \DescribeMacro{arXiv}
% If the |archivePrefix| is present, the |eprint| and the |primaryClass| must also be present and must adhere to the formatting principles of \href{https://arxiv.org/help/arxiv_identifier}{arXiv identifiers}:
@@ -403,6 +426,12 @@ booktitle = {{Proceedings of the International
\RequirePackage{pgfopts}
\pgfkeys{
/bibcop/.cd,
+ notags/.store in=\bibcop@notags,
+ noorg/.store in=\bibcop@noorg,
+ noinproc/.store in=\bibcop@noinproc,
+ nocaps/.store in=\bibcop@nocaps,
+ nodoi/.store in=\bibcop@nodoi,
+ nowraps/.store in=\bibcop@nowraps,
verbose/.store in=\bibcop@verbose,
script/.store in = \bibcop@script,
}
@@ -423,6 +452,25 @@ booktitle = {{Proceedings of the International
% \end{macrocode}
% \end{macro}
+% \begin{macro}{\bibcop@exec}
+% Then, we define a supplementary command to execute the Perl script:
+% \begin{macrocode}
+\makeatletter
+\newcommand\bibcop@exec[1]{
+ \iexec{\bibcop@script\space
+ \ifdefined\bibcop@verbose--verbose\fi\space
+ \ifdefined\bibcop@notags--no:tags\fi\space
+ \ifdefined\bibcop@noinproc--no:org\fi\space
+ \ifdefined\bibcop@noinproc--no:inproc\fi\space
+ \ifdefined\bibcop@nodoi--no:doi\fi\space
+ \ifdefined\bibcop@nocaps--no:caps\fi\space
+ \ifdefined\bibcop@nowraps--no:wraps\fi\space
+ --latex '#1'}%
+ \message{bibcop: style checking finished for #1^^J}%
+}
+\makeatother
+
+
% \begin{macro}{\bibliography}
% Then, we re-define the |\bibliography| command:
% \begin{macrocode}
@@ -430,10 +478,7 @@ booktitle = {{Proceedings of the International
\ifdefined\bibliography
\let\bibcop@oldbibliography\bibliography
\renewcommand\bibliography[1]{%
- \iexec{\bibcop@script\space
- \ifdefined\bibcop@verbose--verbose\fi\space
- --latex '#1.bib'}%
- \message{bibcop: style checking finished^^J}%
+ \bibcop@exec{#1.bib}%
\bibcop@oldbibliography{#1}%
}
\fi
@@ -448,10 +493,7 @@ booktitle = {{Proceedings of the International
\ifdefined\addbibresource
\let\bibcop@oldaddbibresource\addbibresource
\renewcommand\addbibresource[1]{%
- \iexec{\bibcop@script\space
- \ifdefined\bibcop@verbose--verbose\fi\space
- --latex '#1'}%
- \message{bibcop: style checking finished^^J}%
+ \bibcop@exec{#1}%
\bibcop@oldaddbibresource{#1}%
}
\fi
diff --git a/biblio/bibtex/utils/bibcop/bibcop.pdf b/biblio/bibtex/utils/bibcop/bibcop.pdf
index be16c4e36d..feaa27f284 100644
--- a/biblio/bibtex/utils/bibcop/bibcop.pdf
+++ b/biblio/bibtex/utils/bibcop/bibcop.pdf
Binary files differ
diff --git a/biblio/bibtex/utils/bibcop/bibcop.pl b/biblio/bibtex/utils/bibcop/bibcop.pl
index cfe8e3ac47..178e0047bb 100755
--- a/biblio/bibtex/utils/bibcop/bibcop.pl
+++ b/biblio/bibtex/utils/bibcop/bibcop.pl
@@ -44,6 +44,9 @@ my %minors = map { $_ => 1 } qw/in of at to by the a an and or as if up via yet
# Check the presence of mandatory tags.
sub check_mandatory_tags {
+ if (exists $args{'--no:tags'}) {
+ return;
+ }
my (%entry) = @_;
my $type = $entry{':type'};
my $mandatory = $blessed{$type};
@@ -71,6 +74,9 @@ sub check_mandatory_tags {
# Check that all major words are capitalized.
sub check_capitalization {
+ if (exists $args{'--no:caps'}) {
+ return;
+ }
my (%entry) = @_;
my %tags = map { $_ => 1 } qw/title booktitle journal publisher organization/;
foreach my $tag (keys %entry) {
@@ -101,14 +107,21 @@ sub check_capitalization {
# Check that the 'author' is formatted correctly.
sub check_author {
my (%entry) = @_;
- if (exists $entry{'author'} and not $entry{'author'} =~ /^\{.+\}$/) {
- my $author = clean_tex($entry{'author'});
- if (not $author =~ /^[A-Z][^ ]+(,( [A-Z][^ ]+)+)?( and [A-Z][^ ]+(,( [A-Z][^ ]+)+)?)*( and others)?$/) {
- return "The format of the 'author' is wrong, use something like 'Knuth, Donald E. and Duane, Bibby'"
- }
- if ($author =~ /.*[A-Z]([ ,]|$).*/) {
- return "A shortened name must have a tailing dot, as in 'Knuth, Donald E.'"
- }
+ if (not exists $entry{'author'}) {
+ return;
+ }
+ if ($entry{'author'} =~ /^\{.+\}$/) {
+ return;
+ }
+ my $author = clean_tex($entry{'author'});
+ if (index($author, '{') != -1) {
+ return;
+ }
+ if (not $author =~ /^[A-Z][^ ]+(,( [A-Z][^ ]+)+)?( and [A-Z][^ ]+(,( [A-Z][^ ]+)+)?)*( and others)?$/) {
+ return "The format of the 'author' is wrong, use something like 'Knuth, Donald E. and Duane, Bibby'"
+ }
+ if ($author =~ /.*[A-Z]([ ,]|$).*/) {
+ return "A shortened name must have a tailing dot, as in 'Knuth, Donald E.'"
}
}
@@ -134,7 +147,10 @@ sub check_shortenings {
}
# Check the right format of the 'title' and 'booktitle.'
-sub check_titles {
+sub check_wrapping {
+ if (exists $args{'--no:wraps'}) {
+ return;
+ }
my (%entry) = @_;
my @tags = qw/title booktitle/;
foreach my $tag (@tags) {
@@ -177,6 +193,9 @@ sub check_arXiv {
# Check that organization is not mentioned in the booktitle.
sub check_org_in_booktitle {
+ if (exists $args{'--no:org'}) {
+ return;
+ }
my (%entry) = @_;
my @orgs = ( 'ACM', 'IEEE' );
if (exists($entry{'booktitle'})) {
@@ -311,6 +330,9 @@ sub check_year_in_titles {
# Check the right format of the 'booktitle' in the 'inproceedings' entry.
sub check_booktile_of_inproceedings {
+ if (exists $args{'--no:inproc'}) {
+ return;
+ }
my (%entry) = @_;
my $tag = 'inproceedings';
if ($entry{':type'} eq $tag) {
@@ -325,6 +347,9 @@ sub check_booktile_of_inproceedings {
# Check the right format of the 'doi.'
sub check_doi {
+ if (exists $args{'--no:doi'}) {
+ return;
+ }
my (%entry) = @_;
if (exists $entry{'doi'}) {
my $doi = $entry{'doi'};
@@ -339,8 +364,14 @@ sub check_year {
my (%entry) = @_;
if (exists $entry{'year'}) {
my $year = $entry{'year'};
- if (not $year =~ /^[0-9]{3,4}$/) {
- return "The format of the 'year' is wrong"
+ if ($year =~ /^\{.+\}$/) {
+ return;
+ }
+ if (not $year =~ /^[0-9]+$/) {
+ return "The format of the 'year' is wrong, may only contain numbers or must be wrapped in curly braces"
+ }
+ if (not $year =~ /^[0-9]{4}$/) {
+ return "Exactly four digits must be present in the 'year', or it must be wrapped in curly braces"
}
}
}
@@ -391,8 +422,8 @@ sub check_pages {
if ($parts[0] eq $parts[1]) {
return "The 'pages' mentions the same page twice, just use it once"
}
- if ($parts[0] gt $parts[1]) {
- return "The 'pages' are in the wrong order"
+ if ($parts[0] > $parts[1]) {
+ return "The 'pages' are in the wrong order, since $parts[0] is greater than $parts[1]"
}
}
}
@@ -429,7 +460,7 @@ sub process_entry {
foreach my $check (@sorted) {
no strict 'refs';
my $err = $check->(%entry);
- if ($err ne '') {
+ if (defined $err and $err ne '') {
push(@errors, $err);
}
}
@@ -724,10 +755,17 @@ if (@ARGV+0 eq 0 or exists $args{'--help'} or exists $args{'-?'}) {
" -?, --help Print this help screen\n" .
" --fix Fix the errors and print a new version of the .bib file to the console\n" .
" --verbose Print supplementary debugging information\n" .
+ " --no:XXX Disable one of the following checks (e.g. --no:wraps):\n" .
+ " tags Only some tags are allowed, while some of them are mandatory\n" .
+ " caps All major words in titles and booktitles must be capitalized\n" .
+ " wraps Double curly braces are required around titles and booktitles\n" .
+ " doi The presence of the 'doi' tag is mandatory in all entries\n" .
+ " inproc The booktitle of \@inproceedings must start with 'Proceedings of the'\n" .
+ " org The booktitle may not mention ACM or IEEE\n" .
" --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.10');
+ info('0.0.11');
} else {
my ($file) = grep { not($_ =~ /^--.*$/) } @ARGV;
if (not $file) {