Add short-form node anchors

This commit is contained in:
Juno Takano 2025-12-18 11:45:15 -03:00
commit 070b5b7448

View file

@ -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,
} }
} }