diff options
Diffstat (limited to 'library/src/meta/reference.rs')
| -rw-r--r-- | library/src/meta/reference.rs | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/library/src/meta/reference.rs b/library/src/meta/reference.rs index 14246436..0b317db0 100644 --- a/library/src/meta/reference.rs +++ b/library/src/meta/reference.rs @@ -11,6 +11,9 @@ use crate::text::TextElem; /// /// Reference syntax can also be used to [cite]($func/cite) from a bibliography. /// +/// If you just want to link to a labelled element and not get an automatic +/// textual reference, consider using the [`link`]($func/link) function instead. +/// /// # Example /// ```example /// #set heading(numbering: "1.") @@ -93,24 +96,17 @@ impl Show for RefElem { } let target = self.target(); - let matches = vt.introspector.query(Selector::Label(self.target())); + let elem = vt.introspector.query_label(&self.target()); if BibliographyElem::has(vt, &target.0) { - if !matches.is_empty() { + if elem.is_ok() { bail!(self.span(), "label occurs in the document and its bibliography"); } return Ok(self.to_citation(styles).pack()); } - let [elem] = matches.as_slice() else { - bail!(self.span(), if matches.is_empty() { - "label does not exist in the document" - } else { - "label occurs multiple times in the document" - }); - }; - + let elem = elem.at(self.span())?; if !elem.can::<dyn Locatable>() { bail!(self.span(), "cannot reference {}", elem.func().name()); } |
