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; a code
// span reads as its text, without the backticks.
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",
"Oh, `fsl_db` does the expansion, so `f-query` won't choke": "Oh, fsl_db does the expansion, so f-query won't choke",
"a `` tick ` inside `` b": "a tick ` inside b",
"a lone ` tick stays": "a lone ` tick stays",
} {
if got := chatPlain(in); got != want {
t.Errorf("FAIL: %q -> %q, want %q", in, got, want)
}
}
t.Log("ok")
}