Hey!
I’m in the process of updating my code to use typst 0.14 instead of 0.13, and here’s one problem I’m sort-of stuck with. Here’s the code that works with 0.13 (it makes an A3 formatted document out of an A4 formatted one), that I’ve left unmodified, but the real question is about the end of the code, look for the comment:
pub fn create_a3(mut doc: PagedDocument) -> Result<PagedDocument, UserFacing> {
let mut pages = doc.pages;
let len = pages.len();
let page1 = match len {
n @ 0..=2 => {
return Err(UserFacing {
msg: format!("Zu wenige Seiten ({n})"),
source: None,
})
}
3 => None,
4 => pages.pop(),
5 => {
pages.pop();
pages.pop()
}
n @ 6.. => {
return Err(UserFacing {
msg: format!("Zu viele Seiten ({n})"),
source: None,
})
}
};
let [page2, page3, page4] = pages.try_into().map_err(|_| UserFacing {
msg: "Interner Fehler: Falsche Seitenzahl".into(),
source: None,
})?;
let frame1 = merge_frames(page1.map(|p| p.frame), page2.frame);
let frame2 = merge_frames(Some(page3.frame), page4.frame);
let page1 = Page {
frame: frame1,
fill: Default::default(),
numbering: None,
number: 0,
supplement: Content::empty()
};
let page2 = Page {
frame: frame2,
fill: Default::default(),
numbering: None,
number: 0,
supplement: Content::empty()
};
let v = vec![page1, page2];
// This does not work in 0.14.2
doc.introspector = Introspector::paged(&v);
doc.pages = v;
Ok(doc)
}
Now the problem is that Introspector::paged has vanished, and I’m not sure if there’s a replacement. I’ve found this in typsts codebase, which I guess I could simply copy.
Question though, am I missing something, is there an easier way like it was in 0.13? Is there a reason this function is not public? It makes me kinda wary there might be something subtle I’m missing ![]()
Thanks for any answers!