MCPcopy
hub / github.com/vinta/awesome-python / extract_categories_body

Function extract_categories_body

website/build.py:319–337  ·  view source on GitHub ↗

Return content from `Categories` through `Projects`, excluding later sections.

(markdown: str)

Source from the content-addressed store, hash-verified

317
318
319def extract_categories_body(markdown: str) -> str:
320 """Return content from `Categories` through `Projects`, excluding later sections."""
321 lines = markdown.splitlines(keepends=True)
322 start_idx = None
323 end_idx = len(lines)
324 for i, line in enumerate(lines):
325 heading = top_level_heading_text(line)
326 if heading is None:
327 continue
328 if start_idx is None and heading.lower() == "categories":
329 start_idx = i + 1
330 while start_idx < len(lines) and lines[start_idx].strip() == "":
331 start_idx += 1
332 elif start_idx is not None and heading.lower() in ("resources", "contributing"):
333 end_idx = i
334 break
335 if start_idx is None:
336 return ""
337 return "".join(lines[start_idx:end_idx]).rstrip() + "\n"
338
339
340def github_markdown_anchor(text: str) -> str:

Callers 1

build_llms_txtFunction · 0.85

Calls 1

top_level_heading_textFunction · 0.85

Tested by

no test coverage detected