MCPcopy Index your code
hub / github.com/TruthHun/BookStack / handleReleaseV1

Method handleReleaseV1

controllers/api/CommonController.go:872–920  ·  view source on GitHub ↗
(release string, bookIdentify string)

Source from the content-addressed store, hash-verified

870}
871
872func (this *CommonController) handleReleaseV1(release string, bookIdentify string) (htmlStr string) {
873 query, err := goquery.NewDocumentFromReader(bytes.NewBufferString(release))
874 if err != nil {
875 beego.Error(err)
876 } else {
877 // 处理svg
878 query = utils.HandleSVG(query, bookIdentify)
879 query.Find(".reference-link").Remove()
880 query.Find(".header-link").Remove()
881
882 allTags := make(map[string]bool)
883 query.Find("body").Find("*").Each(func(i int, selection *goquery.Selection) {
884 if len(selection.Nodes) > 0 {
885 allTags[strings.ToLower(selection.Nodes[0].Data)] = true
886 }
887 })
888
889 for tag, _ := range allTags {
890 if _, ok := weixinTagsMap.Load(tag); !ok {
891 for len(query.Find(tag).Nodes) > 0 {
892 query.Find(tag).Each(func(i int, selection *goquery.Selection) {
893 if ret, err := selection.Html(); err == nil {
894 selection.BeforeHtml(ret)
895 selection.Remove()
896 }
897 })
898 }
899 }
900 }
901
902 weixinTagsMap.Range(func(tag, value interface{}) bool {
903 t := tag.(string)
904 query.Find(t).AddClass("-" + t).RemoveAttr("id")
905 return true
906 })
907
908 query.Find("img").Each(func(i int, contentSelection *goquery.Selection) {
909 if src, ok := contentSelection.Attr("src"); ok {
910 contentSelection.SetAttr("src", this.completeLink(src))
911 }
912 })
913
914 htmlStr, err = query.Find("body").Html()
915 if err != nil {
916 beego.Error(err)
917 }
918 }
919 return
920}
921
922func (this *CommonController) handleReleaseV2(release, bookIdentify string) interface{} {
923 query, err := goquery.NewDocumentFromReader(bytes.NewBufferString(release))

Callers 1

ReadMethod · 0.95

Calls 3

HandleSVGFunction · 0.92
completeLinkMethod · 0.80
FindMethod · 0.45

Tested by

no test coverage detected