linkify

package module
v0.0.0-...-d2479f1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 2, 2022 License: BSD-2-Clause Imports: 3 Imported by: 0

README

This repository has moved to gitlab.com/golang-commonmark/linkify.

Documentation

Overview

Package linkify provides a way to find links in plain text.

Example
input := `
	Check out this link to http://google.com
You can also email support@example.com to view more.

Some more links: fsf.org http://www.gnu.org/licenses/gpl-3.0.en.html 127.0.0.1
                 localhost:80	github.com/trending?l=Go	//reddit.com/r/golang
mailto:r@golang.org some.nonexistent.host.name flibustahezeous3.onion
`
for _, l := range Links(input) {
	fmt.Printf("Scheme: %-8s  URL: %s\n", l.Scheme, input[l.Start:l.End])
}
Output:

Scheme: http:     URL: http://google.com
Scheme: mailto:   URL: support@example.com
Scheme:           URL: fsf.org
Scheme: http:     URL: http://www.gnu.org/licenses/gpl-3.0.en.html
Scheme:           URL: 127.0.0.1
Scheme:           URL: localhost:80
Scheme:           URL: github.com/trending?l=Go
Scheme: //        URL: //reddit.com/r/golang
Scheme: mailto:   URL: mailto:r@golang.org
Scheme:           URL: some.nonexistent.host.name
Scheme:           URL: flibustahezeous3.onion

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Link struct {
	Scheme     string
	Start, End int
}

Link represents a link found in a string with a schema and a position in the string.

func Links(s string) (links []Link)

Links returns links found in s.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL