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

Function _extract_daily_note_paper_blocks

agents/reading-agent/main.py:2405–2438  ·  view source on GitHub ↗
(content: str)

Source from the content-addressed store, hash-verified

2403
2404def _extract_daily_note_paper_blocks(content: str) -> List[Dict[str, str]]:
2405 text = re.sub(
2406 r"\n?<!-- paperflow-topic-summary:start -->.*?<!-- paperflow-topic-summary:end -->\n?",
2407 "\n",
2408 str(content or ""),
2409 flags=re.DOTALL,
2410 )
2411 sections = list(re.finditer(r"^#\s+(.+)$", text, flags=re.MULTILINE))
2412 blocks: List[Dict[str, str]] = []
2413 for section_index, section in enumerate(sections):
2414 category = section.group(1).strip()
2415 start = section.end()
2416 end = sections[section_index + 1].start() if section_index + 1 < len(sections) else len(text)
2417 body = text[start:end]
2418 matches = list(re.finditer(r"(?m)^<!-- paperflow:[0-9a-f]{16} -->$", body))
2419 for match_index, marker_match in enumerate(matches):
2420 block_start = marker_match.start()
2421 block_end = matches[match_index + 1].start() if match_index + 1 < len(matches) else len(body)
2422 block = body[block_start:block_end].strip()
2423 title_match = re.search(r"(?m)^##\s+(.+)$", block)
2424 if not title_match:
2425 continue
2426 marker = marker_match.group(0).strip()
2427 summary_match = re.search(r"-\s+\*\*(.*?)\*\*", block, flags=re.DOTALL)
2428 blocks.append(
2429 {
2430 "marker": marker,
2431 "title": title_match.group(1).strip(),
2432 "category": category,
2433 "summary": re.sub(r"\s+", " ", summary_match.group(1)).strip() if summary_match else "",
2434 "block": block,
2435 }
2436 )
2437 return blocks
2438
2439
2440def _daily_note_classification_payload(
2441 blocks: List[Dict[str, str]],

Callers 1

Calls 1

startMethod · 0.80

Tested by

no test coverage detected