pub struct Wikilink {
pub target: String,
pub label: Option<String>,
pub span: Range<usize>,
}Expand description
A wikilink embedded in a document’s body: [[target]] or, with an Obsidian
pipe label, [[target|label]].
This is the body-text sibling of a metadata Link. The target is either
a path ([[notes/a.md]], the identity-free Diaryx-style link that moves
rewrite) or a colophon:<id> reference ([[colophon:ajp7eq]], the
location-independent Obsidian-style link that moves leave alone — the
registry update is its maintenance). Which one a workspace mints is a policy
choice; discovering the span is not, so the scanner is neutral between them.
span is the byte range of the whole [[…]] construct in
the source body — exactly what a rewrite replaces, so a path retarget can
splice a new target back in without re-parsing the prose around it.
Fields§
§target: StringThe target as written between [[ and the | (or the closing ]]),
trimmed of surrounding whitespace.
label: Option<String>The display label after |, when written [[target|label]].
span: Range<usize>Byte range of the entire [[…]] span within the scanned body.
Implementations§
Source§impl Wikilink
impl Wikilink
Sourcepub fn render(&self) -> String
pub fn render(&self) -> String
Render back to [[target]] / [[target|label]]. Surrounding whitespace
inside the brackets is not preserved — the rendered form is canonical.
Sourcepub fn with_target(&self, target: impl Into<String>) -> Self
pub fn with_target(&self, target: impl Into<String>) -> Self
This wikilink with a different target, keeping the label — the move path uses it to rewrite a path target while leaving the display text intact. (ID targets are never rewritten; that is the whole point of using one.)
Sourcepub fn id_target(&self) -> Option<Id>
pub fn id_target(&self) -> Option<Id>
The stable ID this wikilink names, when its target uses the id:<id>
scheme (or the legacy colophon:<id> spelling) — None for a plain path
target. Mirrors Link::id_target, including its locator handling:
[[id:abc1234#2]] names the document abc1234.
Trait Implementations§
impl Eq for Wikilink
impl StructuralPartialEq for Wikilink
Auto Trait Implementations§
impl Freeze for Wikilink
impl RefUnwindSafe for Wikilink
impl Send for Wikilink
impl Sync for Wikilink
impl Unpin for Wikilink
impl UnsafeUnpin for Wikilink
impl UnwindSafe for Wikilink
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.