summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock1
-rw-r--r--crates/typst/src/model/introspect.rs8
-rw-r--r--tests/typ/meta/bibliography.typ16
-rw-r--r--tests/typ/meta/link.typ4
-rw-r--r--tests/typ/meta/ref.typ4
5 files changed, 19 insertions, 14 deletions
diff --git a/Cargo.lock b/Cargo.lock
index e271201c..b751a161 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2888,6 +2888,7 @@ dependencies = [
"comemo",
"ecow",
"if_chain",
+ "log",
"serde",
"typst",
"unscanny",
diff --git a/crates/typst/src/model/introspect.rs b/crates/typst/src/model/introspect.rs
index f8a3358e..bd79e5ed 100644
--- a/crates/typst/src/model/introspect.rs
+++ b/crates/typst/src/model/introspect.rs
@@ -5,7 +5,7 @@ use std::hash::Hash;
use std::num::NonZeroUsize;
use comemo::{Prehashed, Track, Tracked, Validate};
-use ecow::{EcoString, EcoVec};
+use ecow::{eco_format, EcoString, EcoVec};
use indexmap::IndexMap;
use super::{Content, Selector};
@@ -388,11 +388,13 @@ impl Introspector {
let mut found = None;
for elem in self.all().filter(|elem| elem.label() == Some(label)) {
if found.is_some() {
- bail!("label occurs multiple times in the document");
+ bail!("label `{}` occurs multiple times in the document", label.repr());
}
found = Some(elem.clone());
}
- found.ok_or_else(|| "label does not exist in the document".into())
+ found.ok_or_else(|| {
+ eco_format!("label `{}` does not exist in the document", label.repr())
+ })
}
/// The total number pages.
diff --git a/tests/typ/meta/bibliography.typ b/tests/typ/meta/bibliography.typ
index 07c17dc6..e3d746e6 100644
--- a/tests/typ/meta/bibliography.typ
+++ b/tests/typ/meta/bibliography.typ
@@ -1,13 +1,6 @@
// Test citations and bibliographies.
---
-// Test ambiguous reference.
-= Introduction <arrgh>
-// Error: 1-7 label occurs in the document and its bibliography
-@arrgh
-#bibliography("/files/works.bib")
-
----
#set page(width: 200pt)
= Details
See also #cite("arrgh", "distress", supplement: [p. 22]), @arrgh[p. 4], and @distress[p. 5].
@@ -41,3 +34,12 @@ And quark! @quark
= Multiple Bibs
Now we have multiple bibliographies containing #cite("glacier-melt", "keshav2007read")
#bibliography(("/files/works.bib", "/files/works_too.bib"))
+
+---
+// Test ambiguous reference.
+= Introduction <arrgh>
+
+// Error: 1-7 label occurs in the document and its bibliography
+@arrgh
+#bibliography("/files/works.bib")
+
diff --git a/tests/typ/meta/link.typ b/tests/typ/meta/link.typ
index 5dfe37e7..f93189cb 100644
--- a/tests/typ/meta/link.typ
+++ b/tests/typ/meta/link.typ
@@ -67,11 +67,11 @@ Text <hey>
#link(<hey>)[Go to text.]
---
-// Error: 2-20 label does not exist in the document
+// Error: 2-20 label `<hey>` does not exist in the document
#link(<hey>)[Nope.]
---
Text <hey>
Text <hey>
-// Error: 2-20 label occurs multiple times in the document
+// Error: 2-20 label `<hey>` occurs multiple times in the document
#link(<hey>)[Nope.]
diff --git a/tests/typ/meta/ref.typ b/tests/typ/meta/ref.typ
index 630bad61..e01bc941 100644
--- a/tests/typ/meta/ref.typ
+++ b/tests/typ/meta/ref.typ
@@ -10,14 +10,14 @@ See @setup.
As seen in @intro, we proceed.
---
-// Error: 1-5 label does not exist in the document
+// Error: 1-5 label `<foo>` does not exist in the document
@foo
---
= First <foo>
= Second <foo>
-// Error: 1-5 label occurs multiple times in the document
+// Error: 1-5 label `<foo>` occurs multiple times in the document
@foo
---