Find all Markdown files and interpret them as chapters.
(markdown_dir: Path)
| 65 | |
| 66 | |
| 67 | def find_markdown_chapters(markdown_dir: Path) -> list[Path]: |
| 68 | """Find all Markdown files and interpret them as chapters.""" |
| 69 | |
| 70 | markdown_entries = list(markdown_dir.rglob("*")) |
| 71 | markdown_entries.sort() |
| 72 | |
| 73 | markdown_chapters = [] |
| 74 | |
| 75 | for markdown_path in markdown_entries: |
| 76 | # Skip privacy policy (regardless of language) |
| 77 | if markdown_path.name.startswith("95_"): |
| 78 | continue |
| 79 | |
| 80 | title = markdown_path.stem.partition("_")[-1].replace("_", " ") |
| 81 | depth = len(markdown_path.relative_to(markdown_dir).parts) - 1 |
| 82 | |
| 83 | markdown_chapters.append( |
| 84 | MarkdownChapter( |
| 85 | title=title, |
| 86 | depth=depth, |
| 87 | contents=markdown_path.read_text() if markdown_path.is_file() else "", |
| 88 | ) |
| 89 | ) |
| 90 | |
| 91 | return markdown_chapters |
| 92 | |
| 93 | |
| 94 | def generate_markdown_preface() -> str: |
no test coverage detected