diff --git a/html2text.go b/html2text.go index f1d2703..682d29a 100644 --- a/html2text.go +++ b/html2text.go @@ -31,7 +31,7 @@ type options struct { func newOptions() *options { // apply defaults return &options{ - lbr: WIN_LBR, + lbr: WIN_LBR, keepSpaces: false, } } @@ -261,7 +261,7 @@ func HTML2TextWithOptions(html string, reqOpts ...Option) string { if tagNameLowercase == "/ul" || tagNameLowercase == "/ol" { outBuf.WriteString(opts.lbr) - } else if tagNameLowercase == "li" || tagNameLowercase == "li/" { + } else if tagNameLowercase == "li" || tagNameLowercase == "li/" || strings.HasPrefix(tagNameLowercase, "li ") { if opts.listPrefix != "" { outBuf.WriteString(opts.lbr + opts.listPrefix) } else { diff --git a/html2text_test.go b/html2text_test.go index 33fa63b..d28afda 100644 --- a/html2text_test.go +++ b/html2text_test.go @@ -127,6 +127,11 @@ func TestHTML2Text(t *testing.T) { So(HTML2Text(`list of items`), ShouldEqual, "list of items\r\nOne\r\nTwo\r\nThree\r\n") }) + Convey("List with classes", func() { + So(HTML2Text(`list of items`), ShouldEqual, "list of items\r\nOne\r\nTwo\r\nThree\r\n") + So(HTML2Text(`list of items
`), ShouldEqual, "list of items\r\nOne\r\nTwo\r\nThree\r\n") + }) + Convey("Optional list support", func() { So(HTML2TextWithOptions(`list of items`, WithListSupport()), ShouldEqual, "list of items\r\n - One\r\n - Two\r\n - Three\r\n") So(HTML2TextWithOptions(`list of items
  1. One
  2. Two
  3. Three
`, WithListSupport()), ShouldEqual, "list of items\r\n - One\r\n - Two\r\n - Three\r\n")