omnifeed

linkfmt

import "github.com/kinorai/omnifeed/internal/linkfmt"

Package linkfmt renders a hyperlink — visible text plus its real target — as plain text an LLM can follow. Engines whose upstream shortens long URLs in the visible text (Discourse cooked HTML, Bluesky link facets) use it so the output keeps the full target instead of a dead, truncated link.

Index

func Link(text, href string) string

Link renders a link whose visible text is text and whose target is href. When the text is just the URL itself — equal to the href or a prefix of it, possibly shortened with a trailing “…”/”…” — the bare href is returned; otherwise markdown [text](href) keeps both. Prefix matching also ignores the href’s http(s):// scheme and a leading “www.”, since clients commonly display links that way (Bluesky shows “example.com/path…” for https://example.com/path/x).

Both arguments must already be decoded (no HTML entities). An empty href returns text unchanged; an empty text returns the bare href.

Generated by gomarkdoc