MCPcopy Create free account
hub / github.com/Graphify-Labs/graphify / parse_markdown

Function parse_markdown

worked/example/raw/parser.py:29–46  ·  view source on GitHub ↗

Extract title, sections, and links from markdown.

(text: str)

Source from the content-addressed store, hash-verified

27
28
29def parse_markdown(text: str) -> dict:
30 """Extract title, sections, and links from markdown."""
31 lines = text.splitlines()
32 title = ""
33 sections = []
34 links = []
35
36 for line in lines:
37 if line.startswith("# ") and not title:
38 title = line[2:].strip()
39 elif line.startswith("## "):
40 sections.append(line[3:].strip())
41 elif "](http" in line:
42 start = line.index("](") + 2
43 end = line.index(")", start)
44 links.append(line[start:end])
45
46 return {"title": title, "sections": sections, "links": links, "format": "markdown"}
47
48
49def parse_json(text: str) -> dict:

Callers 1

parse_fileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected