| 2057 | |
| 2058 | def _extract_report_answer(report_content: str, question: str) -> str: |
| 2059 | text = str(report_content or "") |
| 2060 | if not text.strip(): |
| 2061 | return "" |
| 2062 | escaped = re.escape(question) |
| 2063 | pattern = re.compile( |
| 2064 | rf"(?:^|\n)(?:#+\s*)?Q\d+\s*[::]\s*{escaped}\s*\n+(.*?)(?=\n(?:#+\s*)?Q\d+\s*[::]|\n##\s+|$)", |
| 2065 | flags=re.IGNORECASE | re.DOTALL, |
| 2066 | ) |
| 2067 | match = pattern.search(text) |
| 2068 | if not match: |
| 2069 | return "" |
| 2070 | answer = match.group(1).strip() |
| 2071 | answer = re.sub(r"\n{3,}", "\n\n", answer) |
| 2072 | return answer |
| 2073 | |
| 2074 | |
| 2075 | def _remove_daily_note_entry(current: str, marker: str) -> Optional[str]: |
| 2076 | marker_index = current.find(marker) |