Support multicolumn spans and partial table rules

This commit is contained in:
gloamxun committed 2026-10-19 17:53:26 +08:00
1 parent ca5cb0b8af
commit d4e52dc225
13 files changed
+698 -187

No files matched your search

+34 -2
View File
@@ -244,7 +244,9 @@ pub enum Block {
rows: Vec<Vec<Vec<Run>>>,
caption: Option<Vec<Run>>,
alignments: Vec<ColumnAlignment>,
rules: Vec<usize>,
rules: Vec<TableRule>,
/// Per-cell span and alignment metadata, parallel to `rows`.
cell_styles: Vec<Vec<TableCellStyle>>,
/// Float placement hints from `[htbp]`.
placement: String,
},
@@ -281,13 +283,43 @@ pub enum Block {
PageBreak,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum ColumnAlignment {
Left,
Center,
Right,
}
/// Per-cell table metadata: a multicolumn span and an optional local alignment.
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
pub struct TableCellStyle {
pub colspan: usize,
pub alignment: Option<ColumnAlignment>,
}
/// A horizontal table rule. `end_column` is exclusive; `usize::MAX` means the
/// rule spans every column.
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct TableRule {
pub row: usize,
pub start_column: usize,
pub end_column: usize,
pub trim_left: bool,
pub trim_right: bool,
}
impl TableRule {
pub fn full(row: usize) -> Self {
Self {
row,
start_column: 0,
end_column: usize::MAX,
trim_left: false,
trim_right: false,
}
}
}
#[derive(Clone, PartialEq, Eq, Hash)]
pub struct ListBlock {
pub ordered: bool,