Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow figure dash and en dash as year separator in copyright #12738

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion sphinx/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,8 @@ def _substitute_copyright_year(copyright_line: str, replace_year: str) -> str:
* ``YYYY-YYYY,``
* ``YYYY-YYYY ``

The dash in year ranges may also be figure-dash (U+2012) or en-dash (U+2013).

The final year in the string is replaced with ``replace_year``.
"""
if len(copyright_line) < 4 or not copyright_line[:4].isdigit():
Expand All @@ -659,7 +661,7 @@ def _substitute_copyright_year(copyright_line: str, replace_year: str) -> str:
if copyright_line[4:5] in {'', ' ', ','}:
return replace_year + copyright_line[4:]

if copyright_line[4] != '-':
if copyright_line[4] != '-' and copyright_line[4] != '‒' and copyright_line[4] != '–':
return copyright_line

if copyright_line[5:9].isdigit() and copyright_line[9:10] in {'', ' ', ','}:
Expand Down
4 changes: 4 additions & 0 deletions tests/test_config/test_correct_year.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
# test with SOURCE_DATE_EPOCH set: copyright year should be updated
('1293840000', '2006-2011'),
('1293839999', '2006-2010'),
# figure dash (U+2012)
('1293840000', '2006‒2011'),
# en dash (U+2013)
('1293840000', '2006–2011'),
],

)
Expand Down
Loading