Extract title from markdown file, fallback to filename.
(file_path: Path)
| 91 | |
| 92 | |
| 93 | def get_file_title(file_path: Path) -> str: |
| 94 | """Extract title from markdown file, fallback to filename.""" |
| 95 | try: |
| 96 | content = file_manager.load_text(file_path) |
| 97 | first_line = content.split('\n')[0].strip() |
| 98 | if first_line.startswith('# '): |
| 99 | return first_line[2:].strip() |
| 100 | except Exception: |
| 101 | pass |
| 102 | |
| 103 | # Fallback to filename without extension |
| 104 | return file_path.stem.replace('_', ' ').title() |
| 105 | |
| 106 | |
| 107 | @app.get("/", response_class=HTMLResponse) |
no test coverage detected