Skip to main content

Module linkify

Module linkify 

Source
Expand description

Finding links in plain text.

One detector for everything that asks “is this a link”: autolinking a message body, the markdown [label](url) allowlist, and whether a clicked word is a URL. Keeping them on one scheme list is what stops them disagreeing — a URL that autolinks but may not be written as a markdown link, or the reverse, reads as a bug either way.

The scheme list belongs to the application. A Hotline client wants hotline://, an IRC client ircs://; DEFAULT_SCHEMES is the set every chat client can agree on, and Linkifier::new takes a different one.

Detection is deliberately lenient about what surrounds a URL and strict about what ends one: a link may abut an opening quote or bracket, and sentence punctuation after it is not part of it.

Structs§

Linkifier
A link detector over one scheme list.

Constants§

DEFAULT_SCHEMES
The schemes a view links when the application names none.