Debian Codegraph @

texmf-dist/doc/bibtex/bibcop/README.md

raw
1 # Bibcop: Style Checker of BibTeX .bib files
2
3 ![bibcop logo](bibcop-logo.png)
4
5 [![l3build](https://github.com/yegor256/bibcop/actions/workflows/l3build.yml/badge.svg)](https://github.com/yegor256/bibcop/actions/workflows/l3build.yml)
6 [![CTAN](https://img.shields.io/ctan/v/bibcop)](https://ctan.org/pkg/bibcop)
7 [![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/yegor256/bibcop/blob/master/LICENSE.txt)
8
9 This LaTeX package checks the quality of your `.bib` file and
10 emits warning message if any issues are found. You may also like
11 [biblint](https://github.com/Kingsford-Group/biblint) and
12 [biblatex-check](https://github.com/pezmc/biblatex-check) tools —
13 they do _almost_ the same but from the command line.
14
15 Read [this blog post][BLOG], in order to understand
16 the motivation behind this package.
17
18 First, [install it][INSTALL] from [CTAN](https://ctan.org/pkg/bibcop)
19 and then use in the preamble
20 (if you use [BibTeX](http://www.bibtex.org/), for example):
21
22 ```tex
23 \documentclass{article}
24 \usepackage{bibcop}
25 \begin{document}
26 \bibliographystyle{plain}
27 \bibliography{main}
28 \end{document}
29 ```
30
31 You can also add it as a GitHub Action to your
32 GitHub repository, with the help of
33 [bibcop-action](https://github.com/yegor256/bibcop-action).
34
35 Otherwise, you can download
36 [`bibcop.sty`](https://yegor256.github.io/bibcop/bibcop.sty)
37 and add to your project (together with
38 [`bibcop.pl`](https://yegor256.github.io/bibcop/bibcop.pl)!).
39
40 You can also download
41 [`bibcop.pl`](https://yegor256.github.io/bibcop/bibcop.pl)
42 and use it as a command line tool
43 to check your `.bib` files and to auto-fix them
44 (you should have [Perl](https://www.perl.org) installed):
45
46 ```bash
47 perl bibcop.pl --fix main.bib > fixed.bib
48 ```
49
50 This command will read the `main.bib` file and
51 create `fixed.bib`, which will have the fixed and properly
52 formatted content (well, to some extent).
53 Be careful, all comments will be removed.
54
55 You can also make changes inline, not creating a new file:
56
57 ```bash
58 perl bibcop.pl --fix --in-place main.bib
59 ```
60
61 If you install the package using
62 [`tlmgr`](https://www.tug.org/texlive/tlmgr.html),
63 you should be able to use `bibcop` directly, without the
64 necessity to mention Perl:
65
66 ```bash
67 tlmgr install bibcop
68 bibcop --help
69 ```
70
71 ## How to use as pre-commit hook
72
73 If you use [pre-commit], simply add this to your config:
74
75 ```yaml
76 - repo: https://github.com/yegor256/bibcop
77 rev: 0.0.31
78 hooks:
79 - id: bibcop
80 args: []
81 ```
82
83 ## How to Contribute
84
85 If you want to contribute yourself, make a fork, then create a branch,
86 then run `l3build ctan` in the root directory. It should compile
87 everything without errors. If not, submit an issue and wait.
88 Otherwise, make your changes and then run `l3build ctan` again.
89 If the build is still clean, submit a pull request.
90
91 If you want to add a new check, add it as a Perl subroutine
92 to the `bibcop.pl` file. Don't forget to add a test to one of the test
93 files that stay in the `perl-tests/` directory.
94 When ready, run this, in order to check that all tests pass:
95
96 ```bash
97 perl tests.pl
98 ```
99
100 You should see the `GREAT!` message.
101
102 Copyright (c) 2022-2025 Yegor Bugayenko, MIT License
103
104 [BLOG]: https://www.yegor256.com/2023/09/05/style-checker-for-bibtex-files.html
105 [INSTALL]: https://en.wikibooks.org/wiki/LaTeX/Installing_Extra_Packages
106 [pre-commit]: https://pre-commit.com/