"""How todo-item prints items: as rows of the table `rank_todo.py --help` shows, whatever backend holds the plan, without the Score a markdown plan alone has.""" from plan.todo_table import detail_heading, Item, items_shape, row_cells, tagline_text def table(items: list[Item]) -> str: """A markdown table of items, in their order.""" shape = items_shape(items) columns = [column for column in shape.columns if column != "Score"] rows = [row_cells(item, shape) for item in items] return "\n".join(["| " + " | ".join(columns) + " |", "|" + "---|" * len(columns), *("| " + " | ".join(row.get(column, "") for column in columns) + " |" for row in rows)]) def shown(item: Item) -> str: """item's row under the table's header, then its detail under the heading a markdown plan gives it; the row alone where it has no detail.""" if not item.detail: return table([item]) return f"{table([item])}\n\n{detail_heading(item.id, tagline_text(item.tagline))}\n\n{item.detail}"