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:
@@ -24,7 +24,7 @@ chmod +x run.sh
|
|||||||
out/RealTek-r8169/
|
out/RealTek-r8169/
|
||||||
├── INDEX.md # оглавление со ссылками на главы
|
├── INDEX.md # оглавление со ссылками на главы
|
||||||
├── chapters/ # одна глава = один файл
|
├── chapters/ # одна глава = один файл
|
||||||
│ ├── 01-features.md
|
│ ├── 00001-features.md
|
||||||
│ └── ...
|
│ └── ...
|
||||||
└── assets/ # embedded PNG + page PNG для сломанных layout-страниц
|
└── assets/ # embedded PNG + page PNG для сломанных layout-страниц
|
||||||
```
|
```
|
||||||
|
|||||||
+8
-4
@@ -24,6 +24,7 @@ MIN_CELL_LEN_FOR_DEDUP = 4
|
|||||||
SPACED_LETTERS = re.compile(r"^([A-Z](?: [A-Z]){1,}|[A-Z])$")
|
SPACED_LETTERS = re.compile(r"^([A-Z](?: [A-Z]){1,}|[A-Z])$")
|
||||||
DEFAULT_PAGE_DPI = 150
|
DEFAULT_PAGE_DPI = 150
|
||||||
DEFAULT_CHAPTER_LEVEL = 2
|
DEFAULT_CHAPTER_LEVEL = 2
|
||||||
|
SECTION_INDEX_WIDTH = 5
|
||||||
|
|
||||||
|
|
||||||
def slugify(title: str) -> str:
|
def slugify(title: str) -> str:
|
||||||
@@ -320,9 +321,9 @@ def convert(
|
|||||||
if preamble_pages:
|
if preamble_pages:
|
||||||
sections.append(
|
sections.append(
|
||||||
{
|
{
|
||||||
"num": "00",
|
"num": f"{0:0{SECTION_INDEX_WIDTH}d}",
|
||||||
"title": "front-matter",
|
"title": "front-matter",
|
||||||
"slug": "00-front-matter",
|
"slug": f"{0:0{SECTION_INDEX_WIDTH}d}-front-matter",
|
||||||
"pages": preamble_pages,
|
"pages": preamble_pages,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -339,9 +340,12 @@ def convert(
|
|||||||
continue
|
continue
|
||||||
sections.append(
|
sections.append(
|
||||||
{
|
{
|
||||||
"num": f"{index:02d}",
|
"num": f"{index:0{SECTION_INDEX_WIDTH}d}",
|
||||||
"title": entry["title"],
|
"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,
|
"pages": pages,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user