feat: custom-api new func: parseHTML

pull/844/head
Longlone 2025-10-11 12:11:38 +07:00
parent 36995cc964
commit a3d4cadfa2
1 changed files with 11 additions and 2 deletions

@ -18,6 +18,7 @@ import (
"sync"
"time"
"github.com/PuerkitoBio/goquery"
"github.com/tidwall/gjson"
)
@ -597,6 +598,14 @@ var customAPITemplateFuncs = func() template.FuncMap {
return getCachedRegexp(pattern).ReplaceAllString(s, replacement)
},
"parseHTML": func(body string) *goquery.Document {
doc, err := goquery.NewDocumentFromReader(strings.NewReader(body))
if err != nil {
return nil
}
return doc
},
"findMatch": func(pattern, s string) string {
if s == "" {
return ""