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 <noreply@anthropic.com>
This commit is contained in:
2026-08-22 20:41:11 -04:00
co-authored by Claude Sonnet 5
parent 21a468fb7f
commit 68639a2b5b
+4 -1
View File
@@ -526,7 +526,10 @@ def find_course_thumbnail(course_path: str) -> Optional[str]:
_SECTION_NAME_RE = re.compile( _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
) )