- Center text in each cell
- Escape HTML characters properly
- Fix an unnecessary O(n^2)ism
+- Rare events appear as end-of-line notes rather than mostly-empty columns
## [0.2.1] - 2024-08-20
- A little more space up top
use std::io::BufRead;
use std::iter::Iterator;
-pub struct Config {}
+pub struct Config {
+ pub column_threshold: usize,
+}
const HEADER: &str = r#"<!DOCTYPE html>
<html>
counts.sort_unstable_by(|(an, acol), (bn, bcol)| bn.cmp(an).then(acol.cmp(bcol)));
counts
}
-fn column_order(rows: &[Row]) -> Vec<String> {
+fn column_order(config: &Config, rows: &[Row]) -> Vec<String> {
column_counts(rows)
.into_iter()
- .map(|(_, col)| col)
+ .filter_map(|(n, col)| (n >= config.column_threshold).then_some(col))
.collect()
}
/// * an indented line with no preceding non-indented line
pub fn tablify(config: &Config, input: impl std::io::Read) -> Result<HTML, std::io::Error> {
let rows = read_rows(input).collect::<Result<Vec<_>, _>>()?;
- let columns = column_order(&rows);
+ let columns = column_order(config, &rows);
Ok(HTML(format!(
"{HEADER}{}{}{FOOTER}",
render_column_headers(&columns),