</head>
<body>
<table>
- <tbody>";
+ <tbody>
+";
const FOOTER: &str = " </tbody>
</table>
</body>
)
}
+fn render_column_headers(columns: &[String]) -> String {
+ // TODO: Escape HTML special characters
+ String::from("<th></th>")
+ + &columns
+ .iter()
+ .map(|c| format!("<th>{c}</th>"))
+ .collect::<String>()
+ + "\n"
+}
+
/// # Errors
///
/// Will return `Err` if
let rows = read_rows(input).collect::<Result<Vec<_>, _>>()?;
let columns = column_order(&rows);
Ok(String::from(HEADER)
+ + &render_column_headers(&columns)
+ &rows
.into_iter()
.map(|r| render_row(&columns, &r))