Use five-digit chapter indices

Keep generated chapter filenames and displayed section numbers lexicographically ordered beyond 99 sections.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Сергей Маринкевич
2026-07-15 18:19:54 +07:00
parent 72a7de6146
commit e3ee0aafaf
2 changed files with 9 additions and 5 deletions
+1 -1
View File
@@ -24,7 +24,7 @@ chmod +x run.sh
out/RealTek-r8169/
├── INDEX.md # оглавление со ссылками на главы
├── chapters/ # одна глава = один файл
│ ├── 01-features.md
│ ├── 00001-features.md
│ └── ...
└── assets/ # embedded PNG + page PNG для сломанных layout-страниц
```
+8 -4
View File
@@ -24,6 +24,7 @@ MIN_CELL_LEN_FOR_DEDUP = 4
SPACED_LETTERS = re.compile(r"^([A-Z](?: [A-Z]){1,}|[A-Z])$")
DEFAULT_PAGE_DPI = 150
DEFAULT_CHAPTER_LEVEL = 2
SECTION_INDEX_WIDTH = 5
def slugify(title: str) -> str:
@@ -320,9 +321,9 @@ def convert(
if preamble_pages:
sections.append(
{
"num": "00",
"num": f"{0:0{SECTION_INDEX_WIDTH}d}",
"title": "front-matter",
"slug": "00-front-matter",
"slug": f"{0:0{SECTION_INDEX_WIDTH}d}-front-matter",
"pages": preamble_pages,
}
)
@@ -339,9 +340,12 @@ def convert(
continue
sections.append(
{
"num": f"{index:02d}",
"num": f"{index:0{SECTION_INDEX_WIDTH}d}",
"title": entry["title"],
"slug": f"{index:02d}-{slugify(' - '.join((*entry['parents'], entry['title'])))}",
"slug": (
f"{index:0{SECTION_INDEX_WIDTH}d}-"
f"{slugify(' - '.join((*entry['parents'], entry['title'])))}"
),
"pages": pages,
}
)