Helper functions for @mention parsing and rendering.
Mentions follow the format @[Display Name](user_id) in raw text.
This module provides utilities to parse, render, and extract user IDs
from mention markup.
Summary
Functions
Extract unique user IDs mentioned in text.
Parse mentions from text.
Replace mention markup with display names prefixed by @.
Functions
Extract unique user IDs mentioned in text.
Examples
iex> mentioned_user_ids("Hey @[Alice](u1) and @[Bob](u2) and @[Alice](u1)")
["u1", "u2"]
iex> mentioned_user_ids("No mentions")
[]
iex> mentioned_user_ids(nil)
[]
Parse mentions from text.
Returns a list of maps with :start, :end, :user_id, and :name keys.
Mention format: @[Display Name](user_id)
Examples
iex> parse_mentions("Hello @[Alice](user-1) and @[Bob](user-2)")
[
%{start: 6, end: 26, user_id: "user-1", name: "Alice"},
%{start: 31, end: 49, user_id: "user-2", name: "Bob"}
]
iex> parse_mentions("No mentions here")
[]
iex> parse_mentions(nil)
[]
Replace mention markup with display names prefixed by @.
Transforms @[Display Name](user_id) into @Display Name.
Examples
iex> render_mentions("Hello @[Alice](user-1)!")
"Hello @Alice!"
iex> render_mentions("No mentions")
"No mentions"