fix: update the StripHTMLTags function
- Do not add an extra space between text tokens. - Add a line break if the 'br' tag is detected.
This commit is contained in:
parent
2f38a07cb5
commit
7a3f2928de
1 changed files with 7 additions and 1 deletions
|
@ -43,7 +43,13 @@ func StripHTMLTags(text string) string {
|
||||||
case html.ErrorToken:
|
case html.ErrorToken:
|
||||||
return builder.String()
|
return builder.String()
|
||||||
case html.TextToken:
|
case html.TextToken:
|
||||||
builder.WriteString(token.Token().Data + " ")
|
text := token.Token().String()
|
||||||
|
builder.WriteString(text)
|
||||||
|
case html.StartTagToken:
|
||||||
|
tag := token.Token().String()
|
||||||
|
if tag == "<br>" {
|
||||||
|
builder.WriteString("\n")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue