Remove the first PDF URL and lightweight reading command text.
(text: Any)
| 1099 | |
| 1100 | |
| 1101 | def strip_pdf_url(text: Any) -> str: |
| 1102 | """Remove the first PDF URL and lightweight reading command text.""" |
| 1103 | raw_text = str(text or "") |
| 1104 | stripped = raw_text |
| 1105 | for match in GENERIC_HTTP_URL_RE.finditer(raw_text): |
| 1106 | raw_url = str(match.group("url") or "").strip().rstrip(".,);]\u3002\uff0c\uff1b") |
| 1107 | if not raw_url: |
| 1108 | continue |
| 1109 | normalized_url = raw_url if "://" in raw_url else f"https://{raw_url.lstrip('/')}" |
| 1110 | if looks_like_pdf_http_url(normalized_url): |
| 1111 | stripped = f"{raw_text[:match.start()]} {raw_text[match.end():]}" |
| 1112 | break |
| 1113 | stripped = re.sub(r"(?i)\b(read this|deep read)\b", " ", stripped) |
| 1114 | stripped = re.sub(r"精读", " ", stripped) |
| 1115 | return first_meaningful_line(re.sub(r"\s+", " ", stripped)).strip(" \t\r\n::-") |
| 1116 | |
| 1117 | |
| 1118 | def normalize_direct_pdf_title_hint(text: Any) -> str: |
no test coverage detected