diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-11-17 23:09:23 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-11-17 23:09:23 +0100 |
| commit | 095fa52be5d7ed135f39553359e0253cfea6b71b (patch) | |
| tree | 71e8a71a8b7755b32221a30c32f62cc146acdd33 /src/eval | |
| parent | e869c899bcaefb19c3c47955577396b85494b823 (diff) | |
Placed node
Diffstat (limited to 'src/eval')
| -rw-r--r-- | src/eval/template.rs | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/eval/template.rs b/src/eval/template.rs index 2df347aa..6c1223cb 100644 --- a/src/eval/template.rs +++ b/src/eval/template.rs @@ -10,7 +10,7 @@ use crate::geom::{Align, Dir, GenAxis, Length, Linear, Sides, Size}; use crate::layout::{Layout, PackedNode}; use crate::library::{ Decoration, DocumentNode, FlowChild, FlowNode, PadNode, PageNode, ParChild, ParNode, - Spacing, + PlacedNode, Spacing, }; use crate::style::Style; use crate::util::EcoString; @@ -331,15 +331,21 @@ impl Builder { } /// Push an inline node into the active paragraph. - fn inline(&mut self, node: impl Into<PackedNode>) { + fn inline(&mut self, node: PackedNode) { self.flow.par.push(ParChild::Node(node.into())); } /// Push a block node into the active flow, finishing the active paragraph. - fn block(&mut self, node: impl Into<PackedNode>) { - self.parbreak(); - self.flow.push(FlowChild::Node(node.into())); + fn block(&mut self, node: PackedNode) { self.parbreak(); + let in_flow = node.downcast::<PlacedNode>().is_none(); + self.flow.push(FlowChild::Node(node)); + if in_flow { + self.parbreak(); + } else { + // This prevents duplicate paragraph spacing around placed nodes. + self.flow.last = Last::None; + } } /// Push spacing into the active paragraph or flow depending on the `axis`. |
