pub struct BodyLink {
pub link: Link,
pub span: Range<usize>,
pub image: bool,
}Expand description
One link found in body prose: the parsed Link (target, label, and whether
it was an Obsidian [[…]] wikilink or a markdown/djot [label](target)
link) together with the byte span of the construct —
exactly what a rewrite replaces. The unifying body-link currency: census,
check, and the rename machinery all consume this, blind to which syntax the
link was written in.
An image —  — is one of these too, with image
set, because a move that carries a page’s links and not its pictures leaves
a hole where each picture was. What makes an image different is only the
!, and the span deliberately does not include it: it covers the
[alt](target) that follows, which Link::parse reads and
Link::render reproduces exactly as it does a link’s, so every rewrite
that replaces a span with a rendered link is already right for an image and
none of them can drop the ! by construction.
Fields§
§link: LinkThe parsed link — render reproduces its original
wrapper, so a retargeted [[a]] stays a wikilink and a [t](a) stays a
markdown link.
span: Range<usize>Byte range of the link construct within the scanned body. For an image
this starts at the [ after the !, so the ! sits just before it.
image: boolWhether the construct was an image —  rather than
[label](target). The label is the alt text, and may be empty. An image
names a payload rather than a document, so the census and the spanning
scan leave images out; the rewrites carry them like any path target.
Implementations§
Source§impl BodyLink
impl BodyLink
Sourcepub fn id_target(&self) -> Option<Id>
pub fn id_target(&self) -> Option<Id>
The stable ID this link names, if any — Link::id_target on the inner
link. ID targets are never rewritten by a move.
Sourcepub fn is_path_target(&self) -> bool
pub fn is_path_target(&self) -> bool
Whether this link’s target is a path — Link::is_path_target on the
inner link. The predicate the body-rewrite passes filter on.
Trait Implementations§
impl Eq for BodyLink
impl StructuralPartialEq for BodyLink
Auto Trait Implementations§
impl Freeze for BodyLink
impl RefUnwindSafe for BodyLink
impl Send for BodyLink
impl Sync for BodyLink
impl Unpin for BodyLink
impl UnsafeUnpin for BodyLink
impl UnwindSafe for BodyLink
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.