|
@@ -34,7 +34,7 @@ func StripTags(s string) string {
|
|
return src
|
|
return src
|
|
}
|
|
}
|
|
|
|
|
|
-//自动提取文章摘要
|
|
|
|
|
|
+// 自动提取文章摘要
|
|
func AutoSummary(body string, l int) string {
|
|
func AutoSummary(body string, l int) string {
|
|
|
|
|
|
//匹配图片,如果图片语法是在代码块中,这里同样会处理
|
|
//匹配图片,如果图片语法是在代码块中,这里同样会处理
|
|
@@ -60,7 +60,7 @@ func AutoSummary(body string, l int) string {
|
|
return content
|
|
return content
|
|
}
|
|
}
|
|
|
|
|
|
-//安全处理HTML文档,过滤危险标签和属性.
|
|
|
|
|
|
+// 安全处理HTML文档,过滤危险标签和属性.
|
|
func SafetyProcessor(html string) string {
|
|
func SafetyProcessor(html string) string {
|
|
|
|
|
|
//安全过滤,移除危险标签和属性
|
|
//安全过滤,移除危险标签和属性
|
|
@@ -117,6 +117,8 @@ func SafetyProcessor(html string) string {
|
|
if selector := docQuery.Find("div.markdown-article").First(); selector.Size() <= 0 {
|
|
if selector := docQuery.Find("div.markdown-article").First(); selector.Size() <= 0 {
|
|
if selector := docQuery.Find("div.markdown-toc").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>")
|
|
docQuery.Find("div.markdown-toc").NextAll().WrapAllHtml("<div class=\"markdown-article\"></div>")
|
|
|
|
+ } else if selector := docQuery.Find("dir.toc").First(); selector.Size() > 0 {
|
|
|
|
+ docQuery.Find("dir.toc").NextAll().WrapAllHtml("<div class=\"markdown-article\"></div>")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|