(content: str, *headings: str, max_chars: int = 900)
| 2146 | |
| 2147 | def _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 | |
| 2165 | def _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")) |
no outgoing calls
no test coverage detected