MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / _sections_from_markdown

Function _sections_from_markdown

agents/reading-agent/main.py:2757–2768  ·  view source on GitHub ↗
(markdown: str)

Source from the content-addressed store, hash-verified

2755
2756def _sections_from_markdown(markdown: str) -> Dict[str, str]:
2757 sections: Dict[str, List[str]] = {}
2758 current = "full_text"
2759 for raw_line in str(markdown or "").splitlines():
2760 heading = re.match(r"^\s{0,3}#{1,4}\s+(.+?)\s*$", raw_line)
2761 if heading:
2762 label = re.sub(r"[^a-z0-9]+", "_", heading.group(1).strip().lower()).strip("_") or "section"
2763 current = label[:80]
2764 sections.setdefault(current, [])
2765 continue
2766 sections.setdefault(current, []).append(raw_line)
2767 return {key: _clean_text("\n".join(value)) for key, value in sections.items() if _clean_text("\n".join(value))}
2768
2769
2770def _parse_pdf_url_with_mineru(pdf_url: str) -> Dict[str, Any]:
2771 if not _mineru_enabled():

Callers 1

Calls 1

_clean_textFunction · 0.70

Tested by

no test coverage detected