9个版本 (5个重大更新)
0.6.1 | 2023年7月1日 |
---|---|
0.6.0 | 2023年6月27日 |
0.5.1 |
|
0.4.0 | 2023年6月3日 |
0.1.0 | 2023年5月13日 |
#95 在 值格式化
每月下载量2,634
42KB
765 行
表格格式化工具
此库用于格式化纯文本表格。
示例
代码
use itertools::Itertools;
use table_formatter::{cell, table};
use table_formatter::table::{Align, Border};
let table_header = vec![
cell!("Cell Row").with_width(Some(20)),
cell!("Left", align = Align::Left).with_width(Some(10)),
cell!("Center", align = Align::Center).with_width(Some(10)),
cell!("Right", align = Align::Right).with_width(Some(10)),
];
let table_cells = {
let mut v = (0..=3_u8)
.map(|_| {
vec![
cell!("Cell Row"),
cell!("Left", align = Align::Left),
cell!("Center", align = Align::Center),
cell!("Right", align = Align::Right),
]
})
.collect_vec();
v.push(cell!("Cross Cell!", align = Align::Center).with_span(3));
v
};
let table = table! {
table_header
---
table_cells
with Border::ALL
};
let mut buffer = vec![];
table.render(&mut buffer).unwrap();
println!("{}", String::from_utf8(buffer).unwrap());
输出
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
┃ Cell Row Left Center Right ┃
┃━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┃
┃ Cell Row Left Center Right ┃
┃ Cell Row Left Center Right ┃
┃ Cell Row Left Center Right ┃
┃ Cell Row Left Center Right ┃
┃ Cross Cell! ┃
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
实际上表格的边框是加粗的,但在markdown中无法渲染。
未来计划
等待报告 :)
变更日志
V0.6.0
- 更改了格式化器的API,并添加了宏包装器。
- 添加了文档。
如果您正在使用格式化器,只需将您的
vec!
更改为fmt!
。
V0.5.1
此版本已被删除。
V0.5.0
新功能
- 添加渲染目标:Markdown。
- 添加跨单元格支持。
- 添加宏支持。
警告
此版本与先前版本完全不兼容。
许可证
依赖关系
~0.8–11MB
~80K SLoC