Skip to content

Commit

Permalink
Add fix for broken page numbers (UTF-8 issue)
Browse files Browse the repository at this point in the history
  • Loading branch information
timothygebhard committed Aug 20, 2024
1 parent 837450e commit 27b1576
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions doi2bibtex/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ def postprocess_bibtex(
# Fix broken ampersand in A&A journal name
bibtex_dict = fix_broken_ampersand(bibtex_dict)

# Fix broken page numbers (e.g., "160–175" instead of "160--175")
bibtex_dict = fix_broken_pagenumbers(bibtex_dict)

# Convert escaped LaTeX character to proper Unicode
if config.convert_latex_chars:
bibtex_dict = convert_latex_chars(bibtex_dict)
Expand Down Expand Up @@ -205,6 +208,19 @@ def fix_broken_ampersand(bibtex_dict: dict) -> dict:
return bibtex_dict


def fix_broken_pagenumbers(bibtex_dict: dict) -> dict:
"""
Fix broken pagenumbers (UTF-8 issue: "–" is an en-dash).
"""

if "pages" in bibtex_dict:
bibtex_dict["pages"] = bibtex_dict["pages"].replace(
"–", "--"
)

return bibtex_dict


def format_author_names(bibtex_dict: dict) -> dict:
"""
Clean up the `author` field of a BibTeX entry by splitting it into
Expand Down

0 comments on commit 27b1576

Please sign in to comment.