}
}
-fn read_rows(input: impl std::io::Read) -> Result<Vec<Rowlike>, std::io::Error> {
- Reader::new(std::io::BufReader::new(input).lines()).collect::<Result<Vec<_>, _>>()
+fn read_input(input: impl std::io::Read) -> Result<(Vec<Rowlike>, Config), std::io::Error> {
+ let default_config = Config {
+ column_threshold: 2,
+ };
+ Reader::new(std::io::BufReader::new(input).lines())
+ .collect::<Result<Vec<_>, _>>()
+ .map(|rows| (rows, default_config))
}
fn column_counts(rows: &[Rowlike]) -> Vec<(usize, String)> {
/// * there's an i/o error while reading `input`
/// * the log has invalid syntax:
/// * 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)?;
- let columns = column_order(config, &rows);
+pub fn tablify(input: impl std::io::Read) -> Result<HTML, std::io::Error> {
+ let (rows, config) = read_input(input)?;
+ let columns = column_order(&config, &rows);
Ok(HTML(format!(
"{HEADER}{}{}{FOOTER}",
render_column_headers(&columns),
);
}
+ fn read_rows(input: impl std::io::Read) -> Result<Vec<Rowlike>, std::io::Error> {
+ read_input(input).map(|(rows, _)| rows)
+ }
#[test]
fn test_read_rows() {
assert_eq!(