#[non_exhaustive]pub struct Reference<'a> {
pub xreflabel: Option<Vec<InlineNode<'a>>>,
pub title: Option<Title<'a>>,
pub location: Location,
pub caption: Option<Caption<'a>>,
/* private fields */
}Expand description
Reference metadata for a cross-reference target.
Collected during parsing into the id → Reference map on
Document::references, so a <<id>> reference resolves
to its target’s text in O(1). The id is the map key.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.xreflabel: Option<Vec<InlineNode<'a>>>Optional cross-reference label from reftext= or [[id,xreflabel]],
parsed as inline content. A label carries formatting, so *Bold* label
renders bold. When set, it is the reference text; otherwise converters
use title and, for captioned targets, caption.
title: Option<Title<'a>>The target’s title, when it has one. None for a referenceable element
with no title, such as an untitled block or an inline link with an id
attribute. A reference to such a target renders the literal [id],
unlike an ID that is absent from the catalog and therefore unresolved.
location: LocationLocation of the target element (for navigation, e.g. LSP go-to-definition).
caption: Option<Caption<'a>>The target block’s resolved caption, when it has one.
Implementations§
Source§impl Reference<'_>
impl Reference<'_>
Sourcepub fn section_name(&self) -> Option<&str>
pub fn section_name(&self) -> Option<&str>
The section’s cross-reference category, or None for other targets.
This is part, chapter, section, appendix, or a special section’s
style such as preface. It selects the <name>-refsig attribute.
Sourcepub fn section_number(&self) -> Option<&str>
pub fn section_number(&self) -> Option<&str>
The section’s reference number, without a signifier or trailing punctuation.
Returns None for unnumbered sections and non-section targets. A section
beyond sectnumlevels can have a reference number without a heading number.
use acdc_parser::{Options, parse};
let parsed = parse("= Guide\n:sectnums:\n\n[#intro]\n== Introduction\n", &Options::default())?;
let reference = parsed.document().references.get("intro").ok_or("missing section")?;
assert_eq!(reference.section_name(), Some("section"));
assert_eq!(reference.section_number(), Some("1"));Sourcepub fn is_bibliography(&self) -> bool
pub fn is_bibliography(&self) -> bool
Returns whether this target is a bibliography entry.
Sourcepub fn has_automatic_citation(&self) -> bool
pub fn has_automatic_citation(&self) -> bool
Returns whether the document contains an automatic citation to this target.