This commit is contained in:
xing 2022-09-24 21:48:33 +08:00
parent 735ae5c951
commit 7c4fdc9084

View File

@ -47,11 +47,11 @@ func ExceptRaw(str string, limit, id int) string {
} else { } else {
content = string(ru[:end]) content = string(ru[:end])
closeTag := CloseHtmlTag(content) closeTag := CloseHtmlTag(content)
tmp := `%s......%s<p class="read-more"><a href="/p/%d">继续阅读</a></p>`
if strings.Contains(closeTag, "pre") || strings.Contains(closeTag, "code") { if strings.Contains(closeTag, "pre") || strings.Contains(closeTag, "code") {
content = fmt.Sprintf(`%s%s......<p class="read-more"><a href="/p/%d">继续阅读</a></p>`, content, closeTag, id) tmp = `%s%s......<p class="read-more"><a href="/p/%d">继续阅读</a></p>`
} else {
content = fmt.Sprintf(`%s......%s<p class="read-more"><a href="/p/%d">继续阅读</a></p>`, content, closeTag, id)
} }
content = fmt.Sprintf(tmp, content, closeTag, id)
break break
} }
} }