Ensure that label repr is syntactically valid (#6456)

This commit is contained in:
Laurenz 2025-06-19 09:29:35 +02:00 committed by GitHub
parent 64d0a564bf
commit f32cd5b3e1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -79,7 +79,12 @@ impl Label {
impl Repr for Label {
fn repr(&self) -> EcoString {
eco_format!("<{}>", self.resolve())
let resolved = self.resolve();
if typst_syntax::is_valid_label_literal_id(&resolved) {
eco_format!("<{resolved}>")
} else {
eco_format!("label({})", resolved.repr())
}
}
}