(t *testing.T)
| 5 | ) |
| 6 | |
| 7 | func TestHTML2Text(t *testing.T) { |
| 8 | scenarios := []struct { |
| 9 | html string |
| 10 | expected string |
| 11 | }{ |
| 12 | { |
| 13 | "", |
| 14 | "", |
| 15 | }, |
| 16 | { |
| 17 | "ab c", |
| 18 | "ab c", |
| 19 | }, |
| 20 | { |
| 21 | "<!-- test html comment -->", |
| 22 | "", |
| 23 | }, |
| 24 | { |
| 25 | "<!-- test html comment --> a ", |
| 26 | "a", |
| 27 | }, |
| 28 | { |
| 29 | "<span>a</span>b<span>c</span>", |
| 30 | "abc", |
| 31 | }, |
| 32 | { |
| 33 | `<a href="a/b/c">test</span>`, |
| 34 | "[test](a/b/c)", |
| 35 | }, |
| 36 | { |
| 37 | `<a href="">test</span>`, |
| 38 | "[test]", |
| 39 | }, |
| 40 | { |
| 41 | "<span>a</span> <span>b</span>", |
| 42 | "a b", |
| 43 | }, |
| 44 | { |
| 45 | "<span>a</span> b <span>c</span>", |
| 46 | "a b c", |
| 47 | }, |
| 48 | { |
| 49 | "<span>a</span> b <div>c</div>", |
| 50 | "a b \r\nc", |
| 51 | }, |
| 52 | { |
| 53 | ` |
| 54 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
| 55 | <html xmlns="http://www.w3.org/1999/xhtml"> |
| 56 | <head> |
| 57 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
| 58 | <meta name="viewport" content="width=device-width,initial-scale=1" /> |
| 59 | <style> |
| 60 | body { |
| 61 | padding: 0; |
| 62 | } |
| 63 | </style> |
| 64 | </head> |
nothing calls this directly
no test coverage detected
searching dependent graphs…