(markdown: str)
| 2755 | |
| 2756 | def _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 | |
| 2770 | def _parse_pdf_url_with_mineru(pdf_url: str) -> Dict[str, Any]: |
| 2771 | if not _mineru_enabled(): |
no test coverage detected