package renderkit import ( "strings" "testing" ) func TestMarkdownDropsRawHTMLAndUnsafeLinks(t *testing.T) { out := Markdown("hi [x](javascript:alert(1))\n\n
boom
") for _, bad := range []string{"\" + `a`\n```\n\n``") for _, want := range []string{"bold", "code-block", "copy-btn", "<div>", "<b>"} { if !strings.Contains(out, want) { t.Fatalf("missing %q in:\n%s", want, out) } } } func TestPlainStreamEscapes(t *testing.T) { if got := PlainStream("a\nb"); got != "<b>a</b>
b" { t.Fatal(got) } } // Regression: gomarkdown's Parser panics if reused, which used to make every // reply after the first fail. Also exercised concurrently for the race detector. func TestMarkdownIsReusableAndConcurrencySafe(t *testing.T) { done := make(chan struct{}) for i := 0; i < 8; i++ { go func() { defer func() { done <- struct{}{} }() for j := 0; j < 20; j++ { if out := Markdown("# title\n\ntext"); !strings.Contains(out, "