#markdown-tables #table #structure #data #table-row #format

to_markdown_table

An easy way to format any data structure into a Markdown table

1 unstable release

0.1.1 Apr 1, 2024

#2327 in Data structures

Download history 125/week @ 2024-03-26 73/week @ 2024-04-02 3/week @ 2024-04-09

201 downloads per month

MIT license

8KB
186 lines

to_markdown_table

An easy way to format any data structure into a Markdown table.

[dependencies]
to_markdown_table = "0.1.0"

Example

use to_markdown_table::{MarkdownTable, TableRow};

struct User {
    name: String,
    age: u32
}

impl Into<TableRow> for User {
    fn into(self) -> TableRow {
        TableRow::new(vec![self.name.clone(), self.age.to_string()])
    }
}

let rows = vec![
    User { name: "Jessica".to_string(), age: 28 },
    User { name: "Dennis".to_string(), age: 22 }
];

let table = MarkdownTable::new(vec!["Name".to_string(), "Age".to_string()], rows).unwrap();

println!("{}", table);

lib.rs:

A simple library to create markdown tables.

Example

use to_markdown_table::{MarkdownTable, TableRow};

struct User {
    name: String,
    age: u32
}

impl Into<TableRow> for User {
    fn into(self) -> TableRow {
        TableRow::new(vec![self.name.clone(), self.age.to_string()])
    }
}

let rows = vec![
    User { name: "Jessica".to_string(), age: 28 },
    User { name: "Dennis".to_string(), age: 22 }
];

let table = MarkdownTable::new(Some(vec!["Name".to_string(), "Age".to_string()]), rows).unwrap();

println!("{}", table);

Dependencies

~305–760KB
~18K SLoC