"html"
"html/template"
"regexp"
+ "strings"
"unicode"
"unicode/utf8"
}
if isHTML {
- // Make sure we keep tag of HTML tags
+ // Make sure we keep tagname of HTML tags
slice := text[i:]
m := tagRE.FindStringSubmatchIndex(slice)
if len(m) > 0 && m[0] == 0 {
nextTag = i + m[1]
- tagname := slice[m[4]:m[5]]
+ tagname := strings.Fields(slice[m[4]:m[5]])[0]
lastWordIndex = lastNonSpace
_, singlet := htmlSinglets[tagname]
if !singlet && m[6] == -1 {
{3, template.HTML(strings.Repeat("<p>P</p>", 20)), nil, template.HTML("<p>P</p><p>P</p><p>P …</p>"), false},
{18, template.HTML("<p>test <b>hello</b> test something</p>"), nil, template.HTML("<p>test <b>hello</b> test …</p>"), false},
{4, template.HTML("<p>a<b><i>b</b>c d e</p>"), nil, template.HTML("<p>a<b><i>b</b>c …</p>"), false},
+ {
+ 42,
+ template.HTML(`With strangely formatted
+ <a
+ href="#"
+ target="_blank"
+ >HTML</a
+ >
+ inside.`),
+ nil,
+ template.HTML(`With strangely formatted
+ <a
+ href="#"
+ target="_blank"
+ >HTML …</a>`),
+ false,
+ },
{10, nil, nil, template.HTML(""), true},
{nil, nil, nil, template.HTML(""), true},
}