fix:兼容老文档的TOC

This commit is contained in:
lifei6671
2018-09-14 10:24:41 +08:00
parent 3888ae9673
commit eb8bac4eec
2 changed files with 10 additions and 5 deletions

View File

@@ -105,7 +105,16 @@ func SafetyProcessor(html string) string {
}
}
})
//添加文档标签包裹
if selector := docQuery.Find("article.markdown-article-inner").First(); selector.Size() <= 0 {
docQuery.Children().WrapAllHtml("<article class=\"markdown-article-inner\"></article>")
}
//解决文档内容缺少包裹标签的问题
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("<div class=\"markdown-article\"></div>")
}
}
if html, err := docQuery.Html(); err == nil {