3 releases (breaking)
0.3.0 | Feb 28, 2022 |
---|---|
0.2.0 | Feb 27, 2022 |
0.1.0 | Feb 26, 2022 |
#1394 in Text processing
16KB
307 lines
marko
Programmtically format text with Markdown syntax, with marko!
use marko::{self, Markdown};
use std::collections::HashMap;
fn main() {
let markdown_text = "Finish marko"
.bold()
.link("https://github.com/JosephTLyons/marko")
.task(false);
println!("{}", markdown_text);
// - [ ] [**Finish marko**](https://github.com/JosephTLyons/marko)
println!("{}", marko::divider());
// ---
let rows = [
HashMap::from([
("Name", "Joseph"),
("Profession", "Developer"),
("Age", "31"),
("State", "Indiana"),
]),
HashMap::from([
("Name", "Sam"),
("Profession", "Carpenter"),
("Age", "31"),
("State", "Arizona"),
]),
HashMap::from([
("Name", "Seth"),
("Profession", "Fabricator"),
("Age", "30"),
("State", "Ohio"),
]),
HashMap::from([
("Name", "Danny"),
("Profession", "Guitarist"),
("Age", "31"),
("State", "Indiana"),
]),
];
let mut headers: Vec<_> = rows.first().unwrap().keys().cloned().collect();
headers.sort();
for row in marko::create_markdown_table(&headers, &rows) {
println!("{row}");
}
// | Age | Name | Profession | State |
// | --- | ------ | ---------- | ------- |
// | 31 | Joseph | Developer | Indiana |
// | 31 | Sam | Carpenter | Arizona |
// | 30 | Seth | Fabricator | Ohio |
// | 31 | Danny | Guitarist | Indiana |
}