From b61aebfc257e7b78c4f4dabf0e7e892a136ef14a Mon Sep 17 00:00:00 2001 From: Alister Lewis-Bowen Date: Mon, 13 Apr 2026 08:50:23 -0400 Subject: [PATCH] Fix year-month slug for space-separated filenames Allow a space before the year in the year-month slug pattern, so filenames like "Elektor[nonlinear.ir] 1975-02_text.pdf" are correctly parsed instead of collapsing all months into a single slug. Co-Authored-By: Claude Sonnet 4.6 --- convert.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/convert.py b/convert.py index 2e832ef..e968d68 100644 --- a/convert.py +++ b/convert.py @@ -45,7 +45,7 @@ # Patterns tried in order; first match wins _SLUG_PATTERNS: list[tuple[str, re.Pattern]] = [ # PublicationName-YYYY-MM[...].pdf → YYYY-MM - ("year-month", re.compile(r".*?[_-](\d{4})[_-](\d{2})(?:[_-]|\.|$)", re.IGNORECASE)), + ("year-month", re.compile(r".*?[ _-](\d{4})[_-](\d{2})(?:[_-]|\.|$)", re.IGNORECASE)), # Vol-N or Volume-N → vol-N (bare V excluded: too ambiguous, e.g. _v2 meaning version 2) ("volume", re.compile(r"(?:Vol(?:ume)?)[_\-\.\s]?(\d+)", re.IGNORECASE)), # No-N or Issue-N → no-N