From 68639a2b5b366b36e8f944b0ffb6136915066012 Mon Sep 17 00:00:00 2001 From: rmsitz Date: Sat, 22 Aug 2026 20:41:11 -0400 Subject: [PATCH] Fix chapter-name regex missing underscore-joined folder names _SECTION_NAME_RE used \b after keywords like "chapter", but \b doesn't fire between "Chapter" and an immediately-following "_" since underscore counts as a word character too - so a course whose chapter folders were named "Chapter_1-Introduction" (no space) failed to match and got misclassified as a plain folder instead of a course. Swap \b for a (?![a-z]) negative lookahead, which correctly rejects only a following letter (e.g. "Chapterhouse") while accepting a digit, underscore, hyphen, space, or end of string. Co-Authored-By: Claude Sonnet 5 --- offlineu_core.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/offlineu_core.py b/offlineu_core.py index 7305fd3..4117d8e 100644 --- a/offlineu_core.py +++ b/offlineu_core.py @@ -526,7 +526,10 @@ def find_course_thumbnail(course_path: str) -> Optional[str]: _SECTION_NAME_RE = re.compile( - r'^(section|module|chapter|part|unit|lesson)\b|^\d+[\s_.\-]', re.IGNORECASE + # (?![a-z]) rather than \b after the keyword - \b won't fire between + # "Chapter" and an immediately-following "_" since underscore counts + # as a word character too (e.g. "Chapter_1-Introduction"). + r'^(section|module|chapter|part|unit|lesson)(?![a-z])|^\d+[\s_.\-]', re.IGNORECASE )