Partially fix hide for line, polygon, table, grid (#3139)

This commit is contained in:
Wenzhuo Liu 2024-01-09 16:12:08 +08:00 committed by GitHub
parent 23875a0483
commit cc1f974164
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 78 additions and 0 deletions

View File

@ -376,6 +376,10 @@ impl<'a> GridLayouter<'a> {
self.render_fills_strokes()?;
for frame in &mut self.finished {
frame.meta(self.styles, false);
}
Ok(Fragment::frames(self.finished))
}

View File

@ -236,6 +236,7 @@ impl Layout for ImageElem {
// Create a clipping group if only part of the image should be visible.
if fit == ImageFit::Cover && !target.fits(fitted) {
frame.meta(styles, false);
frame.clip(Path::rect(frame.size()));
}

View File

@ -89,6 +89,7 @@ impl Layout for LineElem {
let mut frame = Frame::soft(target);
let shape = Geometry::Line(delta.to_point()).stroked(stroke);
frame.push(start.to_point(), FrameItem::Shape(shape, self.span()));
frame.meta(styles, false);
Ok(Fragment::frame(frame))
}
}

View File

@ -171,6 +171,7 @@ impl Layout for PolygonElem {
let shape = Shape { geometry: Geometry::Path(path), stroke, fill };
frame.push(Point::zero(), FrameItem::Shape(shape, self.span()));
frame.meta(styles, false);
Ok(Fragment::frame(frame))
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 943 B

After

Width:  |  Height:  |  Size: 48 KiB

View File

@ -3,3 +3,74 @@
---
AB #h(1fr) CD \
#hide[A]B #h(1fr) C#hide[D]
---
Hidden:
#hide[#line(length: 100%)]
#line(length: 100%)
---
Hidden:
#hide(table(rows: 2, columns: 2)[a][b][c][d])
#table(rows: 2, columns: 2)[a][b][c][d]
---
Hidden:
#hide[
#polygon((20%, 0pt),
(60%, 0pt),
(80%, 2cm),
(0%, 2cm),)
]
#polygon((20%, 0pt),
(60%, 0pt),
(80%, 2cm),
(0%, 2cm),)
---
#set rect(
inset: 8pt,
fill: rgb("e4e5ea"),
width: 100%,
)
Hidden:
#hide[
#grid(
columns: (1fr, 1fr, 2fr),
rows: (auto, 40pt),
gutter: 3pt,
rect[A],
rect[B],
rect[C],
rect(height: 100%)[D],
)
]
#grid(
columns: (1fr, 1fr, 2fr),
rows: (auto, 40pt),
gutter: 3pt,
rect[A],
rect[B],
rect[C],
rect(height: 100%)[D],
)
---
Hidden:
#hide[
- 1
- 2
1. A
2. B
- 3
]
- 1
- 2
1. A
2. B
- 3
---
Hidden:
#hide(image("/files/tiger.jpg", width: 5cm, height: 1cm,))
#image("/files/tiger.jpg", width: 5cm, height: 1cm,)