Skip to content

Commit 556c783

Browse files
committed
Drop the month field, is useless
Signed-off-by: Marcello Seri <marcello.seri@gmail.com>
1 parent 8d3f463 commit 556c783

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

bibfmt/lib/bibtex.ml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -617,9 +617,14 @@ let format_entry entry =
617617
in
618618

619619
let formatted_contents =
620-
List.map
621-
(format_entry_content_with_padding max_field_width)
622-
entry.contents
620+
entry.contents
621+
(* DOI's bibtex API adds the "month" field but raises a warning with *)
622+
(* many bib engines, and it is kind of useless. So we filter it out *)
623+
|> List.filter (function
624+
| Field f when String.(lowercase_ascii @@ f.name) = "month" ->
625+
false
626+
| _ -> true)
627+
|> List.map (format_entry_content_with_padding max_field_width)
623628
in
624629
let rec add_commas_except_last = function
625630
| [] -> []

bibfmt/tests/bibfmt.t/run.t

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ Test basic formatting of BibTeX entries by reading from a file
2222
journal = "Celestial Mechanics and Dynamical Astronomy",
2323
publisher = "Springer Science and Business Media LLC",
2424
author = "Bravetti, Alessandro and Seri, Marcello and Vermeeren, Mats and Zadra, Federico",
25-
year = "2020",
26-
month = "jan"
25+
year = "2020"
2726
}
2827

2928
Test formatting BibTeX with braces instead of quotes
@@ -71,8 +70,7 @@ Test writing to output file
7170
journal = "Celestial Mechanics and Dynamical Astronomy",
7271
publisher = "Springer Science and Business Media LLC",
7372
author = "Bravetti, Alessandro and Seri, Marcello and Vermeeren, Mats and Zadra, Federico",
74-
year = "2020",
75-
month = "jan"
73+
year = "2020"
7674
}
7775

7876
Test handling of multiple entries
@@ -164,8 +162,7 @@ Test handling of stdin input
164162
journal = "Celestial Mechanics and Dynamical Astronomy",
165163
publisher = "Springer Science and Business Media LLC",
166164
author = "Bravetti, Alessandro and Seri, Marcello and Vermeeren, Mats and Zadra, Federico",
167-
year = "2020",
168-
month = "jan"
165+
year = "2020"
169166
}
170167

171168
Test parsing of malformed BibTeX (should produce a warning but attempt to return original content)
@@ -198,8 +195,7 @@ Test handling of entries with unquoted values like month abbreviations
198195
title = "Test with unquoted values",
199196
author = "Some Author",
200197
journal = "Some Journal",
201-
year = 2023,
202-
month = {jan}
198+
year = 2023
203199
}
204200

205201
Test URL unescaping in URL fields

0 commit comments

Comments
 (0)