package stringutil
import (
"strings"
"testing"
)
func TestPrepareHTMLForEmbedding(t *testing.T) {
tests := []struct {
name string
in string
contains []string
notContains []string
}{
{
name: "link becomes markdown",
in: `
See the guide for steps.
`,
contains: []string{"See [the guide](https://example.com/guide) for steps."},
notContains: []string{"https://example.com`,
contains: []string{">https://example.com<"},
notContains: []string{
"[https://example.com](https://example.com)",
"Setup inline`,
contains: []string{`Setup`, `inline`},
notContains: []string{"[Setup]"},
},
{
name: "table flattens to header labelled lines",
in: ``,
contains: []string{"", "Plan: Basic | Price: $5", "Plan: Pro | Price: $10"},
notContains: []string{""},
},
{
name: "header only table keeps the header line",
in: ``,
contains: []string{"Plan | Price"},
notContains: []string{""},
},
{
name: "caption leads the table text",
in: ``,
contains: []string{
"Pricing\nBasic | $5",
},
},
{
name: "link inside a table cell survives as markdown",
in: ``,
contains: []string{"Doc: [Pay now](https://example.com/x)"},
notContains: []string{"