summaryrefslogtreecommitdiff
path: root/internal/findlinks/findlinks.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/findlinks/findlinks.go')
-rw-r--r--internal/findlinks/findlinks.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/internal/findlinks/findlinks.go b/internal/findlinks/findlinks.go
index a281a49..ad2e30c 100644
--- a/internal/findlinks/findlinks.go
+++ b/internal/findlinks/findlinks.go
@@ -15,6 +15,14 @@ type Link struct {
Text string
}
+// Format returns a suitable string representation of a link.
+//
+// Argument sep (e.g. " ", "\n") customizes how the href should be
+// displayed alongside the text.
+func Format(link Link, sep string) string {
+ return fmt.Sprintf("%s%s%s", link.Text, sep, link.Href)
+}
+
// FindLinks consumes the given [io.Reader], scraping it of anchor
// tags. Each anchor tag is "unmarshalled" into a [Link]. The
// resulting slice of Links is returned, along with an error.