summaryrefslogtreecommitdiff
path: root/internal/findlinks/findlinks.go
diff options
context:
space:
mode:
authordemo <demo@antix1>2026-05-09 09:58:00 -0400
committerdemo <demo@antix1>2026-05-09 09:58:00 -0400
commit7fe62a3f676d810c8df46fa24a7314a2209a9dd2 (patch)
tree47986644bfe3dcd58ceab737c91c6778e600264f /internal/findlinks/findlinks.go
parent29d93b1089c591b0d9de60f983e5528caa42b7f6 (diff)
feat: use better formatting when printing found links
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.