pub struct Link {
pub text: String,
pub target: String,
pub kind: LinkKind,
}Expand description
A markdown link found in a concept body.
Fields§
§text: StringThe link text (between [ and ]).
target: StringThe raw destination (between ( and )), with any title removed.
kind: LinkKindThe classification of Link::target.
Implementations§
Source§impl Link
impl Link
Sourcepub fn resolve(&self, source: &ConceptId) -> Option<ConceptId>
pub fn resolve(&self, source: &ConceptId) -> Option<ConceptId>
Resolves an internal link to the concept id it points at, given the id of the concept the link appears in.
Returns None for external links, anchors, links to directories
(targets ending in /), or targets that cannot form a valid concept id.
The result is not guaranteed to exist in the bundle: broken links are
permitted by the spec.
Where a target is percent-encoded this returns the literal reading; use
Link::resolve_all to also consider the decoded one.
Sourcepub fn resolve_all(&self, source: &ConceptId) -> Vec<ConceptId>
pub fn resolve_all(&self, source: &ConceptId) -> Vec<ConceptId>
Every concept id this link may denote, most likely first.
A markdown destination is a URL, so a concept whose filename contains a
space is normally linked as /tables/my%20notes.md. Decoding is offered
as a second candidate rather than applied outright, so that a file
genuinely named my%20notes.md still resolves by its literal spelling.
Callers should prefer the first candidate that exists in the bundle.
Sourcepub fn target_without_anchor(&self) -> &str
pub fn target_without_anchor(&self) -> &str
Returns the target with any anchor fragment removed.