if super-long station names get trendy, our fancy station overview pdf can handle them now... except if there is no whitespace :O
This commit is contained in:
parent
6c36e534b9
commit
a0614726cc
@ -21,6 +21,14 @@ pub(crate) async fn station_pdf(stations: Vec<Station>) -> Vec<u8> {
|
||||
#let card_width = 105mm // A4 width (210mm) divided by 2
|
||||
#let card_height = 74.25mm // A4 height (297mm) divided by 4
|
||||
|
||||
#let trimstring(text, max-length) = {
|
||||
if text.len() <= max-length {
|
||||
text
|
||||
} else {
|
||||
text.slice(0, max-length - 3) + "..."
|
||||
}
|
||||
}
|
||||
|
||||
// Custom function to create a card with title and QR code for a URL
|
||||
#let create_url_card(title, url) = {
|
||||
box(
|
||||
@ -33,9 +41,9 @@ pub(crate) async fn station_pdf(stations: Vec<Station>) -> Vec<u8> {
|
||||
),
|
||||
[
|
||||
#align(center + horizon)[
|
||||
#text(weight: "bold", size: 14pt)[Station #title]
|
||||
#text(weight: "bold", size: 14pt)[Station #trimstring(title, 100)]
|
||||
#qr-code(url, width: 4cm)
|
||||
#text(size: 8pt)[#link(url)]
|
||||
#text(size: 11pt)[#link(url)]
|
||||
]
|
||||
]
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user