linking with custom text
This commit is contained in:
parent
93ecf7bb49
commit
0fff91298d
2 changed files with 9 additions and 2 deletions
|
|
@ -26,7 +26,8 @@ binary at target/release/itemse2.
|
|||
- Items and locations can be temporarily taken out of storage, which puts
|
||||
them in "limbo"
|
||||
- Linking to other things in descriptions: `[%type%:%id%]`, e.g.
|
||||
`[location:019830dd-3b1b-7543-8fb9-8ccfdb1c6456]`
|
||||
`[location:019830dd-3b1b-7543-8fb9-8ccfdb1c6456]` (append an additional
|
||||
`:` followed by any text to customize the displayed link text)
|
||||
|
||||
## Usage
|
||||
|
||||
|
|
|
|||
|
|
@ -1093,9 +1093,15 @@ fn description(inp: &str) -> String {
|
|||
static RE_LINK: LazyLock<Regex> = LazyLock::new(|| {
|
||||
Regex::new(r"\[(item|location|itemtype|note):([0-9a-fA-F\-]+)\]").unwrap()
|
||||
});
|
||||
static RE_LINK_CUSTOM: LazyLock<Regex> = LazyLock::new(|| {
|
||||
Regex::new(r"\[(item|location|itemtype|note):([0-9a-fA-F\-]+):([^]]+)\]").unwrap()
|
||||
});
|
||||
RE_LINK
|
||||
.replace_all(
|
||||
&inp.replace("<", "<").replace(">", ">"),
|
||||
&RE_LINK_CUSTOM.replace_all(
|
||||
&inp.replace("<", "<").replace(">", ">"),
|
||||
"<a href=/$1/$2>[$3]</a>",
|
||||
),
|
||||
"<a href=/$1/$2>[$1]</a>",
|
||||
)
|
||||
.to_string()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue