Custom checks: allow to specify error level (warning or error)
kiryph opened this issue · 1 comments
kiryph commented
my.bib
:
@article{Koch:1984,
author = {Koch, E.},
doi = {10.1107/S0108767384001227},
issn = {0108-7673},
journal = {Acta Crystallographica Section A Foundations of Crystallography},
month = {sep},
number = {5},
pages = {593--600},
title = {The implications of normalizers on group–subgroup relations between space groups},
volume = {40},
year = {1984}
}
@Article{Dove:1997,
author = {Dove, Martin T.},
title = {Theory of displacive phase transitions in minerals},
doi = {10.2138/am-1997-3-401},
issn = {0003-004X},
journal = {American Mineralogist},
month = {apr},
number = {3-4},
pages = {213--244},
volume = {82},
year = {1997}
}
@article{Koch:1984,
author = {Koch, E.},
doi = {10.1107/S0108767384001227},
issn = {0108-7673},
journal = {Acta Crystallographica Section A Foundations of Crystallography},
month = {sep},
number = {5},
pages = {593--600},
title = {The implications of normalizers on group–subgroup relations between space groups},
volume = {40},
year = {1984}
}
% Semantic checks
check.rule { month "^[\"{]1?[0-9][\"}]$" }
check.rule { month "" "\@ \$: Month has to be a suitable number\n" }
❯ bibtool -r .bibtoolrsc my.bib > /dev/null
*** BibTool: Article koch:1984: Month has to be a suitable number
*** BibTool: Article dove:1997: Month has to be a suitable number
*** BibTool: Article koch:1984: Month has to be a suitable number
I would like to specify that this is a warning not an error similar to
*** BibTool ERROR: (line 3 in ./z.bib): Unexpected character encountered
*** BibTool WARNING: (line 5 in ./z.bib): 17 non-space characters ignored.
The output should be like
❯ bibtool -r .bibtoolrsc my.bib > /dev/null
*** BibTool WARNING: Article koch:1984: Month has to be a suitable number
*** BibTool WARNING: Article dove:1997: Month has to be a suitable number
*** BibTool WARNING: Article koch:1984: Month has to be a suitable number
This is useful when bibtool is run as a linter and the messages are categorized into errors and warnings.
ge-ne commented
Resources check.warning.rule and check.error.rule introduced for this.