Package su.onno.ui.comments
Class Mentions
java.lang.Object
su.onno.ui.comments.Mentions
The on-the-wire syntax for a comment link:
@[Display](kind/name/id) for a mention and
#[Display](kind/name/id) for a reference. Keeping the link in the text
(rather than in a side table) means Comment.body stays a single string. The
Display carried in the token is only a snapshot for fallback; the live display,
avatar and read access are resolved at render time by MentionResolver.
This class is a pure, side-effect-free parser/serializer (round-trip tested). The name
segment is the URL-safe route name (snake_case), so the same token body is also a navigable
onno:// route on the client.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordOne mention occurrence found in a body: its ref, the snapshot label, and the exact matched text. -
Method Summary
Modifier and TypeMethodDescriptionstatic Stringdegrade(String body, Predicate<MentionRef> degrade) Rewrite a body, degrading every mention whose ref satisfiesdegradeto its plain label text (the token's display snapshot).static List<Mentions.Occurrence> occurrences(String body) Every mention occurrence in body order (duplicates included), or empty when there are none.static List<MentionRef> The distinct mention refs in a body, first-seen order preserved.static List<MentionRef> The distinct refs for one marker (@mentions or#references), first-seen.static StringThe URL-safe route segment for a logical name: snake_case, mirroring the client'stoSnakeCase(andSurfaceDivBuilder.routeNameOf) so a mention token's route is the same one a list-row tap or ref link produces.static StringsanitizeLabel(String label) A label safe to embed between[and]: collapse newlines and drop].static Stringtoken(char marker, String label, MentionRef ref) Serialize a mention or reference to its token form.static Stringtoken(String label, MentionRef ref) Serialize a mention to its token form.
-
Method Details
-
token
Serialize a mention to its token form. The label is sanitized so it can't break the syntax. -
token
Serialize a mention or reference to its token form. -
sanitizeLabel
A label safe to embed between[and]: collapse newlines and drop]. -
occurrences
Every mention occurrence in body order (duplicates included), or empty when there are none. -
parse
The distinct mention refs in a body, first-seen order preserved. -
parse
The distinct refs for one marker (@mentions or#references), first-seen. -
degrade
Rewrite a body, degrading every mention whose ref satisfiesdegradeto its plain label text (the token's display snapshot). Used on POST to strip mentions the author can't read, so a stored comment never smuggles a clickable link to a hidden record. -
routeName
The URL-safe route segment for a logical name: snake_case, mirroring the client'stoSnakeCase(andSurfaceDivBuilder.routeNameOf) so a mention token's route is the same one a list-row tap or ref link produces.
-