mirror of
https://github.com/typst/typst
synced 2025-05-14 04:56:26 +08:00
35 lines
818 B
Rust
35 lines
818 B
Rust
use crate::library::prelude::*;
|
|
|
|
/// Hide a node without affecting layout.
|
|
#[derive(Debug, Hash)]
|
|
pub struct HideNode(pub LayoutNode);
|
|
|
|
#[node]
|
|
impl HideNode {
|
|
fn construct(_: &mut Machine, args: &mut Args) -> TypResult<Content> {
|
|
Ok(Content::inline(Self(args.expect("body")?)))
|
|
}
|
|
}
|
|
|
|
impl Layout for HideNode {
|
|
fn layout(
|
|
&self,
|
|
ctx: &mut Context,
|
|
regions: &Regions,
|
|
styles: StyleChain,
|
|
) -> TypResult<Vec<Arc<Frame>>> {
|
|
let mut frames = self.0.layout(ctx, regions, styles)?;
|
|
|
|
// Clear the frames.
|
|
for frame in &mut frames {
|
|
*frame = Arc::new({
|
|
let mut empty = Frame::new(frame.size);
|
|
empty.baseline = frame.baseline;
|
|
empty
|
|
});
|
|
}
|
|
|
|
Ok(frames)
|
|
}
|
|
}
|