Run patched ``mandoc -T markdown `` to get markdown directly.
(gz_path: str)
| 43 | |
| 44 | |
| 45 | def get_manpage_text(gz_path: str) -> str: |
| 46 | """Run patched ``mandoc -T markdown <gz_path>`` to get markdown directly.""" |
| 47 | if not os.path.isfile(gz_path): |
| 48 | raise FileNotFoundError(f"manpage file not found: {gz_path}") |
| 49 | result = subprocess.run( |
| 50 | [config.MANDOC_PATH, "-T", "markdown", gz_path], |
| 51 | capture_output=True, |
| 52 | text=True, |
| 53 | timeout=60, |
| 54 | ) |
| 55 | if result.returncode != 0 or not result.stdout.strip(): |
| 56 | raise ExtractionError( |
| 57 | f"mandoc failed for {gz_path}: {result.stderr}", |
| 58 | reason_class=FailureReason.MANDOC_FAILED, |
| 59 | ) |
| 60 | return result.stdout.strip() |
| 61 | |
| 62 | |
| 63 | def _split_sections(text: str) -> list[tuple[int, str]]: |