diff options
author | Karl Berry <karl@freefriends.org> | 2022-12-13 21:08:43 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2022-12-13 21:08:43 +0000 |
commit | 76fbbeea8ed397248b62a749f2d8a22ea8aad062 (patch) | |
tree | 4b76501c0e09ea652abfbe80869e8d2d1f5c5f0c | |
parent | 37acdfb25ae9a280366c6ee994127edc42badf9b (diff) |
bibcop (13dec22)
git-svn-id: svn://tug.org/texlive/trunk@65265 c570f23f-e606-0410-a88d-b1316a301751
-rwxr-xr-x | Build/source/texk/texlive/linked_scripts/bibcop/bibcop.pl | 74 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/bibcop/DEPENDS.txt | 1 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/bibcop/README.md | 9 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/bibcop/bibcop.pdf | bin | 330862 -> 331588 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/man/man1/bibcop.1 | 29 | ||||
-rw-r--r-- | Master/texmf-dist/doc/man/man1/bibcop.man1.pdf | bin | 0 -> 13208 bytes | |||
-rwxr-xr-x | Master/texmf-dist/scripts/bibcop/bibcop.pl | 74 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/bibcop/bibcop.dtx | 62 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/bibcop/bibcop.sty | 11 | ||||
-rwxr-xr-x | Master/tlpkg/libexec/ctan2tds | 1 |
10 files changed, 177 insertions, 84 deletions
diff --git a/Build/source/texk/texlive/linked_scripts/bibcop/bibcop.pl b/Build/source/texk/texlive/linked_scripts/bibcop/bibcop.pl index 3fa1444b92c..8b900bbc35e 100755 --- a/Build/source/texk/texlive/linked_scripts/bibcop/bibcop.pl +++ b/Build/source/texk/texlive/linked_scripts/bibcop/bibcop.pl @@ -26,6 +26,9 @@ package bibcop; use warnings; use strict; +# Hash of incoming command line arguments. +my %args = map { $_ => 1 } @ARGV; + # If you want to add an extra check, just create a new procedure # named as "check_*". @@ -237,6 +240,17 @@ sub check_volume { } } +# Check the right format of the 'number.' +sub check_number { + my (%item) = @_; + if (exists $item{'number'}) { + my $number = $item{'number'}; + if (not $item{'number'} =~ /^[1-9][0-9]*$/) { + return "The format of the 'number' is wrong" + } + } +} + # Check the right format of the 'pages.' sub check_pages { my (%item) = @_; @@ -387,8 +401,9 @@ sub only_words { sub clean_tex { my ($tex) = @_; $tex =~ s/\s+/ /g; - $tex =~ s/^\{+//g; - $tex =~ s/\}+$//g; + $tex =~ s/^\s+//g; + $tex =~ s/\s+$//g; + while ($tex =~ s/^\{(.+)\}$/$1/g) {}; return $tex; } @@ -406,7 +421,32 @@ sub listed_keys { return '(' . join(', ', @sorted) . ')'; } -my %args = map { $_ => 1 } @ARGV; +# Print ERROR message to the console and die. +sub error { + my ($txt) = @_; + print $txt . "\n"; + exit 1; +} + +# Print DEBUG message to the console. +sub debug { + my ($txt) = @_; + if (exists $args{'--latex'}) { + print '% '; + } + print $txt . "\n"; +} + +# Print INFO message to the console. +sub warning { + my ($txt) = @_; + if (exists $args{'--latex'}) { + print "\\PackageWarningNoLine{bibcop}{$txt}\n"; + } else { + print $txt . "\n"; + } +} + if (@ARGV+0 eq 0 or exists $args{'--help'}) { debug("Bibcop is a Style Checker of .bib Files\n" . "Usage: bibcop [<options>] <.bib file path>\n" . @@ -415,7 +455,7 @@ if (@ARGV+0 eq 0 or exists $args{'--help'}) { " --fix Fix the errors and print a new version of the .bib file to the console\n" . " --latex Report errors in LaTeX format using \\PackageWarningNoLine command"); } elsif (exists $args{'--version'}) { - debug('0.0.2'); + debug('0.0.3'); } else { my ($file) = grep { not($_ =~ /^--.*$/) } @ARGV; open(my $fh, '<', $file); @@ -463,30 +503,4 @@ if (@ARGV+0 eq 0 or exists $args{'--help'}) { } } -# Print ERROR message to the console and die. -sub error { - my ($txt) = @_; - print $txt . "\n"; - exit 1; -} - -# Print DEBUG message to the console. -sub debug { - my ($txt) = @_; - if (exists $args{'--latex'}) { - print '% '; - } - print $txt . "\n"; -} - -# Print INFO message to the console. -sub warning { - my ($txt) = @_; - if (exists $args{'--latex'}) { - print "\\PackageWarningNoLine{bibcop}{$txt}\n"; - } else { - print $txt . "\n"; - } -} - 1; diff --git a/Master/texmf-dist/doc/latex/bibcop/DEPENDS.txt b/Master/texmf-dist/doc/latex/bibcop/DEPENDS.txt index 08a680f05bf..424bb3f506c 100644 --- a/Master/texmf-dist/doc/latex/bibcop/DEPENDS.txt +++ b/Master/texmf-dist/doc/latex/bibcop/DEPENDS.txt @@ -1,3 +1,2 @@ hard iexec -hard fancyvrb hard verbatimcopy
\ No newline at end of file diff --git a/Master/texmf-dist/doc/latex/bibcop/README.md b/Master/texmf-dist/doc/latex/bibcop/README.md index b3cbd2ef8a3..08672deb1a5 100644 --- a/Master/texmf-dist/doc/latex/bibcop/README.md +++ b/Master/texmf-dist/doc/latex/bibcop/README.md @@ -1,4 +1,4 @@ -<img src="https://raw.githubusercontent.com/yegor256/bibcop/master/logo.svg" height="92px"/> +<img src="https://raw.githubusercontent.com/yegor256/bibcop/master/bibcop-logo.svg" height="92px"/> [![l3build](https://github.com/yegor256/bibcop/actions/workflows/l3build.yml/badge.svg)](https://github.com/yegor256/bibcop/actions/workflows/l3build.yml) [![CTAN](https://img.shields.io/ctan/v/bibcop)](https://ctan.org/pkg/bibcop) @@ -26,10 +26,11 @@ Otherwise, you can download [`bibcop.sty`](https://raw.githubusercontent.com/yeg You can also download [bibcop.pl](https://raw.githubusercontent.com/yegor256/bibcop/master/bibcop.pl) and use it as a command line tool -to check your `.bib` files and to auto-fix them: +to check your `.bib` files and to auto-fix them +(you should have [Perl](https://www.perl.org) installed): ``` -$ ./bibcop.pl --fix main.bib > fixed.bib +$ perl bibcop.pl --fix main.bib > fixed.bib ``` This command will read the `main.bib` file and create `fixed.bib`, which @@ -48,7 +49,7 @@ Don't forget to add a test to one of the test files that stay in the `perl-tests When ready, run this, in order to check that all tests pass: ```bash -$ ./tests.pl +$ perl tests.pl ``` You should see the `GREAT!` message.
\ No newline at end of file diff --git a/Master/texmf-dist/doc/latex/bibcop/bibcop.pdf b/Master/texmf-dist/doc/latex/bibcop/bibcop.pdf Binary files differindex a8320c97a13..09901670e8e 100644 --- a/Master/texmf-dist/doc/latex/bibcop/bibcop.pdf +++ b/Master/texmf-dist/doc/latex/bibcop/bibcop.pdf diff --git a/Master/texmf-dist/doc/man/man1/bibcop.1 b/Master/texmf-dist/doc/man/man1/bibcop.1 new file mode 100644 index 00000000000..8f92e426299 --- /dev/null +++ b/Master/texmf-dist/doc/man/man1/bibcop.1 @@ -0,0 +1,29 @@ +.TH bibcop 1 "2022-12-13" +.SH NAME +bibcop \- Style Checker and Fixer of .bib Files +.SH SYNOPSIS +bibcop [<options>] <.bib file path> +.SH DESCRIPTION +The bibcop tool is a Perl script for checking the quality of .bib +files and automatically fixing found inconsistencies. It is not only +a command line tool, but a LaTeX package, which can check the quality +of a .bib file during the rendering of a LaTeX document. All found +issues are reported as LaTeX warnings. +.SH OPTIONS +Various options apply +.IP --version +Print the version of the tool +.IP --help +Print the introduction screen +.IP --fix +Autho-fix all issues and print a new content to the console +.IP --latex +Print everything in LaTeX format +.SH BUGS +.SH AUTHOR +Yegor Bugayenko (yegor256@gmail.com) +.PP +Please log issues on the GitHub homepage: +https://github.com/yegor256/bibcop/issues. +.SH SEE ALSO +See bibcop.pdf for more details. diff --git a/Master/texmf-dist/doc/man/man1/bibcop.man1.pdf b/Master/texmf-dist/doc/man/man1/bibcop.man1.pdf Binary files differnew file mode 100644 index 00000000000..d5ad447a980 --- /dev/null +++ b/Master/texmf-dist/doc/man/man1/bibcop.man1.pdf diff --git a/Master/texmf-dist/scripts/bibcop/bibcop.pl b/Master/texmf-dist/scripts/bibcop/bibcop.pl index 3fa1444b92c..8b900bbc35e 100755 --- a/Master/texmf-dist/scripts/bibcop/bibcop.pl +++ b/Master/texmf-dist/scripts/bibcop/bibcop.pl @@ -26,6 +26,9 @@ package bibcop; use warnings; use strict; +# Hash of incoming command line arguments. +my %args = map { $_ => 1 } @ARGV; + # If you want to add an extra check, just create a new procedure # named as "check_*". @@ -237,6 +240,17 @@ sub check_volume { } } +# Check the right format of the 'number.' +sub check_number { + my (%item) = @_; + if (exists $item{'number'}) { + my $number = $item{'number'}; + if (not $item{'number'} =~ /^[1-9][0-9]*$/) { + return "The format of the 'number' is wrong" + } + } +} + # Check the right format of the 'pages.' sub check_pages { my (%item) = @_; @@ -387,8 +401,9 @@ sub only_words { sub clean_tex { my ($tex) = @_; $tex =~ s/\s+/ /g; - $tex =~ s/^\{+//g; - $tex =~ s/\}+$//g; + $tex =~ s/^\s+//g; + $tex =~ s/\s+$//g; + while ($tex =~ s/^\{(.+)\}$/$1/g) {}; return $tex; } @@ -406,7 +421,32 @@ sub listed_keys { return '(' . join(', ', @sorted) . ')'; } -my %args = map { $_ => 1 } @ARGV; +# Print ERROR message to the console and die. +sub error { + my ($txt) = @_; + print $txt . "\n"; + exit 1; +} + +# Print DEBUG message to the console. +sub debug { + my ($txt) = @_; + if (exists $args{'--latex'}) { + print '% '; + } + print $txt . "\n"; +} + +# Print INFO message to the console. +sub warning { + my ($txt) = @_; + if (exists $args{'--latex'}) { + print "\\PackageWarningNoLine{bibcop}{$txt}\n"; + } else { + print $txt . "\n"; + } +} + if (@ARGV+0 eq 0 or exists $args{'--help'}) { debug("Bibcop is a Style Checker of .bib Files\n" . "Usage: bibcop [<options>] <.bib file path>\n" . @@ -415,7 +455,7 @@ if (@ARGV+0 eq 0 or exists $args{'--help'}) { " --fix Fix the errors and print a new version of the .bib file to the console\n" . " --latex Report errors in LaTeX format using \\PackageWarningNoLine command"); } elsif (exists $args{'--version'}) { - debug('0.0.2'); + debug('0.0.3'); } else { my ($file) = grep { not($_ =~ /^--.*$/) } @ARGV; open(my $fh, '<', $file); @@ -463,30 +503,4 @@ if (@ARGV+0 eq 0 or exists $args{'--help'}) { } } -# Print ERROR message to the console and die. -sub error { - my ($txt) = @_; - print $txt . "\n"; - exit 1; -} - -# Print DEBUG message to the console. -sub debug { - my ($txt) = @_; - if (exists $args{'--latex'}) { - print '% '; - } - print $txt . "\n"; -} - -# Print INFO message to the console. -sub warning { - my ($txt) = @_; - if (exists $args{'--latex'}) { - print "\\PackageWarningNoLine{bibcop}{$txt}\n"; - } else { - print $txt . "\n"; - } -} - 1; diff --git a/Master/texmf-dist/source/latex/bibcop/bibcop.dtx b/Master/texmf-dist/source/latex/bibcop/bibcop.dtx index 07d513b49fc..36c8ac747bd 100644 --- a/Master/texmf-dist/source/latex/bibcop/bibcop.dtx +++ b/Master/texmf-dist/source/latex/bibcop/bibcop.dtx @@ -50,7 +50,7 @@ %<package>\NeedsTeXFormat{LaTeX2e} %<package>\ProvidesPackage{bibcop} %<*package> -[2022-12-12 0.0.2 Style Checker of Bibliography Files] +[2022-12-13 0.0.3 Style Checker of Bibliography Files] %</package> %<*driver> \documentclass{ltxdoc} @@ -105,14 +105,15 @@ %\iffalse %</verb> %\fi -% You may see warnings in the \TeX log. Fix the issues in the |main.bib| file +% You may see warnings in the \TeX{} log --- fix the issues in the |main.bib| file % and the warnings will disappear. % If you use the |.sty| file (without installing it into the \TeX{} tree), don't forget % to also copy the |bibcop.pl| file --- it is the Perl script that does all the work % of checking your |.bib| files. The |.sty| is just a simple wrapper around it. -% Make sure |\usepackage{bibcop}| stays before all other |\usepackage| commands, otherwise +% Make sure |\usepackage{bibcop}| stays right after |\usepackage{biblatex}| +% (if you use it), otherwise % you won't see any warnings from |bibcop|. % \section{The Rules} @@ -132,7 +133,8 @@ % Every bib item must have the |doi| key, which is a unique % \href{https://www.doi.org}{Digital Object Identifier} % of the material that you reference. It seems to be a good practice, in order to avoid ambiguity, -% to always mention the DOI. +% to always mention the DOI. I would also recommend to use \href{https://ctan.org/pkg/iexec}{doi} package, +% in order to make all ``|doi|'' fields turned into hyper links. % \DescribeMacro{caps} % In |title|, |booktitle|, and |journal| keys, all major words must be capitalized, @@ -149,6 +151,18 @@ title = {A Preliminary Architecture for a Basic Data-Flow Processor} % Here, the leading ``|A|'' is capital because it opens the title. % The word ``|for|'' and the article ``|a|'' are minor words, that's why they are in lower case. % Both parts of the composite word ``|Data-Flow|'' are capitalized. +% Sometimes you need to violate this rule and use custom capitalization, as it is done +% by the author of the paper. In order to do this, wrap the words with custom capitalization +% in curled brackets, for example: +%\iffalse +%<*verb> +%\fi +\begin{verbatim} +title = {Structured Programming {with} Go {To} Statements} +\end{verbatim} +%\iffalse +%</verb> +%\fi % \DescribeMacro{author} % The |author| must contain a list of authors separated by ``|and|''. Each author @@ -259,6 +273,18 @@ volume = {32}, %</verb> %\fi +% \DescribeMacro{number} +% The |number| may contain only a number: +%\iffalse +%<*verb> +%\fi +\begin{verbatim} +number = {132}, +\end{verbatim} +%\iffalse +%</verb> +%\fi + % \DescribeMacro{pages} % The |pages| may contain either a number or two numbers separated by a double dash: %\iffalse @@ -311,12 +337,14 @@ booktitle = {{Proceedings of the International % Then, we re-define the |\bibliography| command: % \begin{macrocode} \makeatletter -\ifdefined\bibliography\else\gdef\bibliography#1{}\fi -\let\bibcop@oldbibliography\bibliography -\renewcommand\bibliography[1]{% - \iexec{perl "./bibcop.tmp.pl" --latex '#1.bib'}% - \bibcop@oldbibliography{#1}% -} +\ifdefined\bibliography + \let\bibcop@oldbibliography\bibliography + \renewcommand\bibliography[1]{% + \iexec{perl "./bibcop.tmp.pl" --latex '#1.bib'}% + \message{bibcop: style checking finished^^J}% + \bibcop@oldbibliography{#1}% + } +\fi \makeatother % \end{macrocode} % \end{macro} @@ -325,12 +353,14 @@ booktitle = {{Proceedings of the International % Then, we re-define the |\addbibresource| command: % \begin{macrocode} \makeatletter -\ifdefined\addbibresource\else\gdef\addbibresource#1{}\fi -\let\bibcop@oldaddbibresource\addbibresource -\renewcommand\addbibresource[1]{% - \iexec{perl "./bibcop.tmp.pl" --latex '#1'}% - \bibcop@oldaddbibresource{#1}% -} +\ifdefined\addbibresource + \let\bibcop@oldaddbibresource\addbibresource + \renewcommand\addbibresource[1]{% + \iexec{perl "./bibcop.tmp.pl" --latex '#1'}% + \message{bibcop: style checking finished^^J}% + \bibcop@oldaddbibresource{#1}% + } +\fi \makeatother % \end{macrocode} % \end{macro} diff --git a/Master/texmf-dist/tex/latex/bibcop/bibcop.sty b/Master/texmf-dist/tex/latex/bibcop/bibcop.sty index ff48a3c02d9..e992cd05bfb 100644 --- a/Master/texmf-dist/tex/latex/bibcop/bibcop.sty +++ b/Master/texmf-dist/tex/latex/bibcop/bibcop.sty @@ -31,7 +31,8 @@ \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{bibcop} -[2022-12-12 0.0.2 Style Checker of Bibliography Files] +[2022-12-13 0.0.3 Style Checker of Bibliography Files] + @@ -60,21 +61,25 @@ \message{bibcop: File with Perl script 'bibcop.pl' copied^^J}% \makeatletter -\ifdefined\bibliography\else\gdef\bibliography#1{}\fi +\ifdefined\bibliography \let\bibcop@oldbibliography\bibliography \renewcommand\bibliography[1]{% \iexec{perl "./bibcop.tmp.pl" --latex '#1.bib'}% + \message{bibcop: style checking finished^^J}% \bibcop@oldbibliography{#1}% } +\fi \makeatother \makeatletter -\ifdefined\addbibresource\else\gdef\addbibresource#1{}\fi +\ifdefined\addbibresource \let\bibcop@oldaddbibresource\addbibresource \renewcommand\addbibresource[1]{% \iexec{perl "./bibcop.tmp.pl" --latex '#1'}% + \message{bibcop: style checking finished^^J}% \bibcop@oldaddbibresource{#1}% } +\fi \makeatother diff --git a/Master/tlpkg/libexec/ctan2tds b/Master/tlpkg/libexec/ctan2tds index eb95f3513e4..dd78b21898f 100755 --- a/Master/tlpkg/libexec/ctan2tds +++ b/Master/tlpkg/libexec/ctan2tds @@ -3689,6 +3689,7 @@ $standardttf = '\.ttf|\.TTC'; 'a2ping' => '\.1$', 'axodraw2' => '\.1$', 'bib2gls' => '\.1$', + 'bibcop' => '\.1$', 'bundledoc' => '\.1$', 'chklref' => '\.1$', 'citation-style-language' => '\.1$', |