Skip to content

Commit

Permalink
Fix issue #155: styled table rows disappear.
Browse files Browse the repository at this point in the history
  • Loading branch information
jugglerchris committed May 31, 2024
1 parent 0e1682a commit 6b020b7
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -892,6 +892,20 @@ impl<'a, C: 'a, N> TreeMapResult<'a, C, N, RenderNode> {
cellinfo.content = vec![wrapped];
RenderNode::new(RenderNodeInfo::TableCell(cellinfo))
}
RenderNodeInfo::TableRow(mut row, vert) => {
let cells = row.cells;
let cells = cells
.into_iter()
.map(|mut child| {
let children = child.content;
let wrapped = RenderNode::new(f(children));
child.content = vec![wrapped];
child
})
.collect();
row.cells = cells;
RenderNode::new(RenderNodeInfo::TableRow(row, vert))
}
ni => RenderNode::new(f(vec![RenderNode::new(ni)])),
}
}))
Expand Down
32 changes: 32 additions & 0 deletions src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2388,6 +2388,38 @@ Baz
r#"X<R>CD</R>Y
<G>C</G>D
"#,
20,
);
}

#[test]
fn test_colour_row() {
test_html_coloured(
br#"<head><style>
tr.r {
color: #f00;
}
</style></head><body>
<table>
<tr>
<td>Row</td><td>One</td>
</tr>
<tr class="r">
<td>Row</td><td>Two</td>
</tr>
<tr>
<td>Row</td><td>Three</td>
</tr>
</table>
"#,
r#"───┬─────
Row│One
───┼─────
<R>Row</R>│<R>Two</R>
───┼─────
Row│Three
───┴─────
"#,
20,
);
Expand Down

0 comments on commit 6b020b7

Please sign in to comment.