Turn any technical book PDF into a Claude Code skill — ready to study, reference, and use while you work.
Python agent-skillsai-agentsbook-to-skillcontext-engineeringdocument-processingedtechknowledge-baseknowledge-managementllmpdf-to-markdownragself-studystudy-tools
fix(extractor): detect whitespace-separated CJK ToC headers (#112)
Aryan Singh K.e7980f3fc97f
diff --git a/book_to_skill/utils.py b/book_to_skill/utils.pyindex 918da86..fa3cd5d 100644--- a/book_to_skill/utils.py+++ b/book_to_skill/utils.py@@ -158,14 +158,16 @@ _KO_CHAPTER = re.compile(# line (^\s*X\s*$) so an inline "the contents of this chapter" never matches._TOC_HEADERS = ("table of contents", "contents", "índice", "sumário", # EN / ES / PT- "目录", "目錄", "目次", # Chinese / Japanese"table des matières", # French"inhaltsverzeichnis", # German"indice", "sommario", # Italian (no accent — distinct from índice above)"inhoudsopgave", # Dutch)+_TOC_CJK_PATTERN = r"目[ \t\u3000]*(?:录|錄|次)"_TOC_PATTERN = re.compile(- r"^\s*(?:" + "|".join(re.escape(h) for h in _TOC_HEADERS) + r")\s*$",+ r"^\s*(?:"+ + "|".join([*(re.escape(h) for h in _TOC_HEADERS), _TOC_CJK_PATTERN])+ + r")\s*$",re.IGNORECASE | re.MULTILINE,)diff --git a/tests/test_book_to_skill.py b/tests/test_book_to_skill.pyindex 538a5f1..724898b 100644--- a/tests/test_book_to_skill.py+++ b/tests/test_book_to_skill.py@@ -715,6 +715,10 @@ class TestDetectStructure:def test_toc_traditional_chinese(self):assert detect_structure("目錄\n第一章")["has_toc"] is True+ @pytest.mark.parametrize("header", ["目 录", "目 录", "目 次", "目 次"])+ def test_toc_cjk_headers_allow_extracted_whitespace(self, header):+ assert detect_structure(f"{header}\n第一章 开始\n第二章 进阶")["has_toc"] is True+def test_toc_italian_sommario(self):assert detect_structure("Sommario\n1 Introduzione")["has_toc"] is True