from __future__ import annotations from typing import Iterable, Sequence def md_table(headers: Sequence[str], rows: Iterable[Sequence[str]]) -> str: """Render a simple GitHub-flavored Markdown table. Args: headers: Column header strings. rows: Row values. Returns: Markdown table as a single string. """ header_line = "| " + " | ".join(str(h) for h in headers) + " |" sep_line = "| " + " | ".join(["---"] * len(headers)) + " |" body_lines = ["| " + " | ".join(str(cell) for cell in row) + " |" for row in rows] return "\n".join([header_line, sep_line, *body_lines])