Integrate native repeat boxes and PDF bookmarks

This commit is contained in:
gloamxun committed 2026-11-19 16:06:28 +08:00
1 parent 5163fc9854
commit 38e4822370
33 files changed
+1208 -143

No files matched your search

@@ -15,6 +15,11 @@ pub enum DiagnosticNode {
value: Glue,
name: Option<Parameter>,
},
Leaders {
value: Glue,
mode: LeaderMode,
pattern: Box<DiagnosticNode>,
},
Kern {
width: i32,
explicit: bool,
@@ -74,6 +79,18 @@ pub(super) fn box_view(b: &NativeBox) -> DiagnosticBox {
nodes,
}
}
fn leader_node(leader: &LeaderGlue) -> DiagnosticNode {
let pattern = match &leader.pattern {
LeaderPattern::Box(b) => DiagnosticNode::Box(box_view(b)),
LeaderPattern::Rule(r) => DiagnosticNode::Rule(*r),
};
DiagnosticNode::Leaders {
value: leader.glue,
mode: leader.mode,
pattern: Box::new(pattern),
}
}
fn vertical_nodes(nodes: &[NativeVerticalNode]) -> Vec<DiagnosticNode> {
nodes
.iter()
@@ -88,6 +105,7 @@ fn vertical_nodes(nodes: &[NativeVerticalNode]) -> Vec<DiagnosticNode> {
value: *g,
name: Some(*p),
},
NativeVerticalNode::Leaders(leader) => leader_node(leader),
NativeVerticalNode::Kern(k) => DiagnosticNode::Kern {
width: *k,
explicit: true,
@@ -190,6 +208,7 @@ pub(super) fn text_nodes(nodes: &[TextNode]) -> Vec<DiagnosticNode> {
value: *g,
name: None,
},
TextNode::Leaders(leader) => leader_node(leader),
TextNode::Kern { width, explicit } => DiagnosticNode::Kern {
width: *width,
explicit: *explicit,
@@ -435,6 +454,23 @@ impl Printer<'_> {
self.number(*w as i64);
}
DiagnosticNode::Glue { value, name } => self.glue(*value, *name),
DiagnosticNode::Leaders {
value,
mode,
pattern,
} => {
self.command(match mode {
LeaderMode::Aligned => "leaders",
LeaderMode::Centered => "cleaders",
LeaderMode::Expanded => "xleaders",
});
self.literal(" ");
self.glue_spec(*value);
self.nodes(
std::slice::from_ref(pattern.as_ref()),
&format!("{prefix}."),
)?;
}
DiagnosticNode::Kern { width, explicit } => {
self.command("kern");
if *explicit {