Check if a roff line is a section header (.SH or .Sh) matching name.
(line: str, name: str)
| 53 | |
| 54 | |
| 55 | def _is_section_header(line: str, name: str) -> bool: |
| 56 | """Check if a roff line is a section header (.SH or .Sh) matching name.""" |
| 57 | stripped = line.strip() |
| 58 | # man(7): .SH NAME / .SH "NAME"; mdoc(7): .Sh NAME |
| 59 | for macro in (".SH", ".Sh"): |
| 60 | if stripped.startswith(macro): |
| 61 | rest = stripped[len(macro) :].strip().strip('"').strip() |
| 62 | if rest.upper() == name.upper(): |
| 63 | return True |
| 64 | return False |
| 65 | |
| 66 | |
| 67 | def _is_any_section_header(line: str) -> bool: |