Extract profile-level citation stats when the sidebar table is available.
(html_text: str)
| 641 | if not value: |
| 642 | return "" |
| 643 | without_scripts = re.sub(r"(?is)<(script|style)[^>]*>.*?</\1>", " ", value) |
| 644 | plain = re.sub(r"(?s)<[^>]+>", " ", without_scripts) |
| 645 | return _collapse_whitespace(html.unescape(plain)) |
| 646 | |
| 647 | |
| 648 | def _extract_first_group(pattern: str, text: str) -> str: |
| 649 | """Return the first non-empty capture group for a regex search.""" |
| 650 | match = re.search(pattern, text or "", re.IGNORECASE | re.DOTALL) |
| 651 | if not match: |
| 652 | return "" |
| 653 | for group in match.groups(): |
| 654 | if group: |
| 655 | return group |
| 656 | return match.group(0) |
| 657 | |
| 658 | |
| 659 | def _build_scholar_profile_url( |
no test coverage detected