Documentation
¶
Overview ¶
Package link finds the URLs in a piece of text.
A terminal that speaks OSC 8 will make a range of cells clickable, and [grid.Cell] carries the target for exactly that. What it cannot do is work out which part of a line is a URL in the first place — that is this package, and it is a surprising amount of care for what looks like one regular expression.
What is not here ¶
Opening one. Which browser, whether the process is sandboxed, whether a URL from tool output should be opened at all — none of that is a terminal library's to decide, and a library that decided would be a framework for one program. The answer is a byte range and a target; what happens on a click is the caller's.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Link ¶
type Link struct {
// Start and End are the byte range of the text that was matched, which is what
// a caller stamps the target onto with [grid.View.Link].
Start, End int
// URL is the target. It is not always the matched text: a bare host is given
// the scheme it was written without.
URL string
}
Link is one URL found in a piece of text.