Check whether an index entry already exists inside the named section.
(lines: list[str], heading: str, link: str)
| 857 | |
| 858 | |
| 859 | def _section_contains_link(lines: list[str], heading: str, link: str) -> bool: |
| 860 | """Check whether an index entry already exists inside the named section.""" |
| 861 | bounds = _get_section_bounds(lines, heading) |
| 862 | if bounds is None: |
| 863 | return False |
| 864 | |
| 865 | start, end = bounds |
| 866 | entry_prefix = f"- {link}" |
| 867 | return any(line.startswith(entry_prefix) for line in lines[start:end]) |
| 868 | |
| 869 | |
| 870 | def _replace_section_entry(lines: list[str], heading: str, link: str, entry: str) -> bool: |
no test coverage detected