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: `
PlanPrice
Basic$5
Pro$10
`, contains: []string{"
", "Plan: Basic | Price: $5", "Plan: Pro | Price: $10"},
			notContains: []string{""},
		},
		{
			name:        "header only table keeps the header line",
			in:          `
PlanPrice
`, contains: []string{"Plan | Price"}, notContains: []string{""}, }, { name: "caption leads the table text", in: `
Pricing
Basic$5
`, contains: []string{ "Pricing\nBasic | $5", }, }, { name: "link inside a table cell survives as markdown", in: `
Doc
Pay now
`, contains: []string{"Doc: [Pay now](https://example.com/x)"}, notContains: []string{"