diff --git a/models/DocumentModel.go b/models/DocumentModel.go index 6d4015cb..58806ce7 100644 --- a/models/DocumentModel.go +++ b/models/DocumentModel.go @@ -291,8 +291,6 @@ func (item *Document) Processor() *Document { selector.AppendHtml(content.String()) } else if selector := docQuery.Find("article.markdown-article-inner").First(); selector.Size() > 0 { selector.AppendHtml(content.String()) - } else { - docQuery.Children().WrapHtml("
").AppendHtml(content.String()) } } } @@ -316,8 +314,6 @@ func (item *Document) Processor() *Document { selector.AppendHtml(release) } else if selector := docQuery.Find("article.markdown-article-inner").First(); selector.Size() > 0 { selector.First().AppendHtml(release) - } else { - docQuery.Children().WrapHtml("
").AppendHtml(release); } } diff --git a/utils/html.go b/utils/html.go index c3075899..7ab91c6d 100644 --- a/utils/html.go +++ b/utils/html.go @@ -105,7 +105,16 @@ func SafetyProcessor(html string) string { } } }) - + //添加文档标签包裹 + if selector := docQuery.Find("article.markdown-article-inner").First(); selector.Size() <= 0 { + docQuery.Children().WrapAllHtml("
") + } + //解决文档内容缺少包裹标签的问题 + if selector := docQuery.Find("div.markdown-article").First(); selector.Size() <= 0 { + if selector := docQuery.Find("div.markdown-toc").First(); selector.Size() > 0 { + docQuery.Find("div.markdown-toc").NextAll().WrapAllHtml("
") + } + } if html, err := docQuery.Html(); err == nil {