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

Function _markdown_section_excerpt

agents/reading-agent/main.py:2148–2163  ·  view source on GitHub ↗
(content: str, *headings: str, max_chars: int = 900)

Source from the content-addressed store, hash-verified

2146
2147def _markdown_section_excerpt(content: str, *headings: str, max_chars: int = 900) -> str:
2148 text = str(content or "")
2149 for heading in headings:
2150 pattern = re.compile(
2151 rf"(?ms)^##\s+{re.escape(heading)}\s*$\n+(.*?)(?=^##\s+|\Z)"
2152 )
2153 match = pattern.search(text)
2154 if not match:
2155 continue
2156 excerpt = match.group(1).strip()
2157 excerpt = re.sub(r"(?m)^>\s*", "", excerpt)
2158 excerpt = re.sub(r"(?m)^[-*]\s+", "", excerpt)
2159 excerpt = re.sub(r"\n{3,}", "\n\n", excerpt).strip()
2160 if excerpt:
2161 return excerpt[:max_chars].rstrip()
2162 return ""
2163
2164
2165def _report_paper_from_metadata(metadata: Dict[str, Any], report: Dict[str, Any]) -> Dict[str, Any]:
2166 title = _clean_text(metadata.get("title") or report.get("title"))

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected