Skip to content
quarry Artifact [427b5a7090]
Login

Artifact [427b5a7090]

Artifact 427b5a7090ce7379e4b3a09d399e13c7af08cc962406ee48762aef1b8f899871:


package api

import "testing"

// A digest quotes a chat line as prose: a link reads as its text, and
// so does an anchor a line bridged from fossil still carries.
func TestADigestQuotesLinksAsTheirWords(t *testing.T) {
	for in, want := range map[string]string{
		"see [6df13eaedc](https://f.example/r/x/info/6df13eaedc) now":                                                                       "see 6df13eaedc now",
		"(check-in: <a href='/r/libfossil/info/6df13eaedc'>6df13eaedc</a>, user: <a href='/r/libfossil/timeline?u=d&c=6df'>danshearer</a>)": "(check-in: 6df13eaedc, user: danshearer)",
		`a [b\]c](u) d`: "a b]c d",
		"<https://fossil-scm.org/home/info/f9c2d23f297f23cd>": "https://fossil-scm.org/home/info/f9c2d23f297f23cd",
		"see <http://a.example/x> and <b>":                    "see http://a.example/x and <b>",
		"plain *markdown* stays":                              "plain *markdown* stays",
	} {
		if got := chatPlain(in); got != want {
			t.Errorf("FAIL: %q -> %q, want %q", in, got, want)
		}
	}
	t.Log("ok")
}