Add short-form node anchors
This commit is contained in:
parent
198bc12507
commit
070b5b7448
1 changed files with 8 additions and 2 deletions
|
|
@ -48,11 +48,17 @@ impl Parseable for Anchor {
|
||||||
assert!(parts.len() == 2, "Parts should always be 2: {parts:?}");
|
assert!(parts.len() == 2, "Parts should always be 2: {parts:?}");
|
||||||
|
|
||||||
let text = parts.first().unwrap_or_else(|| unreachable!());
|
let text = parts.first().unwrap_or_else(|| unreachable!());
|
||||||
let destination = parts.get(1).unwrap_or_else(|| unreachable!());
|
let raw_destination = parts.get(1).unwrap_or_else(|| unreachable!());
|
||||||
|
let destination =
|
||||||
|
if raw_destination.contains(":") || raw_destination.contains("/") {
|
||||||
|
raw_destination.to_owned()
|
||||||
|
} else {
|
||||||
|
format!("/node/{raw_destination}")
|
||||||
|
};
|
||||||
|
|
||||||
Anchor {
|
Anchor {
|
||||||
text: text.to_owned(),
|
text: text.to_owned(),
|
||||||
destination: destination.to_owned(),
|
destination,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue