Compare commits

..

No commits in common. "0bc68df2a9a87ca7e36e34dab56b07c666d64760" and "64d0a564bf92b6540955d820149e62e7fab394c5" have entirely different histories.

3 changed files with 5 additions and 18 deletions

View File

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

View File

@ -5,7 +5,7 @@ use crate::diag::{bail, At, Hint, SourceResult};
use crate::engine::Engine; use crate::engine::Engine;
use crate::foundations::{ use crate::foundations::{
cast, elem, Cast, Content, Context, Func, IntoValue, Label, NativeElement, Packed, cast, elem, Cast, Content, Context, Func, IntoValue, Label, NativeElement, Packed,
Repr, Show, Smart, StyleChain, Synthesize, Show, Smart, StyleChain, Synthesize,
}; };
use crate::introspection::{Counter, CounterKey, Locatable}; use crate::introspection::{Counter, CounterKey, Locatable};
use crate::math::EquationElem; use crate::math::EquationElem;
@ -229,15 +229,8 @@ impl Show for Packed<RefElem> {
// RefForm::Normal // RefForm::Normal
if BibliographyElem::has(engine, self.target) { if BibliographyElem::has(engine, self.target) {
if let Ok(elem) = elem { if elem.is_ok() {
bail!( bail!(span, "label occurs in the document and its bibliography");
span,
"label `{}` occurs both in the document and its bibliography",
self.target.repr();
hint: "change either the {}'s label or the \
bibliography key to resolve the ambiguity",
elem.func().name(),
);
} }
return Ok(to_citation(self, engine, styles)?.pack().spanned(span)); return Ok(to_citation(self, engine, styles)?.pack().spanned(span));

View File

@ -51,8 +51,7 @@ $ A = 1 $ <eq2>
// Test ambiguous reference. // Test ambiguous reference.
= Introduction <arrgh> = Introduction <arrgh>
// Error: 1-7 label `<arrgh>` occurs both in the document and its bibliography // Error: 1-7 label occurs in the document and its bibliography
// Hint: 1-7 change either the heading's label or the bibliography key to resolve the ambiguity
@arrgh @arrgh
#bibliography("/assets/bib/works.bib") #bibliography("/assets/bib/works.bib")