package doc import ( "strings" "testing" ) // A GFM table must come out inside .table-scroll. Without the wrapper a table of // bare URLs cannot shrink to its grid column and paints over the document's // table-of-contents rail. func TestTableIsWrappedForScrolling(t *testing.T) { src := "| Date | URL |\n|---|---|\n| 2026-07-21 | https://example.com/a |\n" html := renderMD(t, src).HTML if !strings.Contains(html, `
`) { t.Errorf("table not wrapped:\n%s", html) } if !strings.Contains(html, "
") { t.Errorf("wrapper not closed:\n%s", html) } // The rows still go through goldmark's own renderer. if !strings.Contains(html, "") || !strings.Contains(html, "") { t.Errorf("table body lost:\n%s", html) } } func TestRenderInline(t *testing.T) { r := NewRenderer() cases := []struct { name string in string want string }{ {"wikilink", "[[eatonphil-bookclub]]", `eatonphil-bookclub`}, {"pdf attachment", "[[paper.pdf]]", `paper.pdf`}, {"several values", "[[alpha]], [[beta]]", `alpha, beta`}, {"bare url is autolinked", "https://example.com/x", `https://example.com/x`}, {"unresolved link stays visible", "[[missing-thing]]", `missing-thing`}, {"plain text", "want-to-read", "want-to-read"}, } for _, c := range cases { t.Run(c.name, func(t *testing.T) { if got := r.RenderInline([]byte(c.in), "specs", fakeResolver{}); got != c.want { t.Errorf("RenderInline(%q)\n got: %s\nwant: %s", c.in, got, c.want) } }) } }