mirror of
https://codeberg.org/scip/epuppy.git
synced 2025-12-17 20:41:00 +01:00
clean svg and cdata
This commit is contained in:
@@ -10,7 +10,8 @@ import (
|
|||||||
var (
|
var (
|
||||||
cleanentitles = regexp.MustCompile(`&[a-z]+;`)
|
cleanentitles = regexp.MustCompile(`&[a-z]+;`)
|
||||||
empty = regexp.MustCompile(`(?s)^[\s ]*$`)
|
empty = regexp.MustCompile(`(?s)^[\s ]*$`)
|
||||||
newlines = regexp.MustCompile(`[\r\n]+`)
|
newlines = regexp.MustCompile(`[\r\n\s]+`)
|
||||||
|
cleansvg = regexp.MustCompile(`(<svg.+</svg>|<!\[CDATA\[.+\]\]>)`)
|
||||||
cleanmarkup = regexp.MustCompile(`<[^<>]+>`)
|
cleanmarkup = regexp.MustCompile(`<[^<>]+>`)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -27,7 +28,8 @@ type Content struct {
|
|||||||
func (c *Content) String(content []byte) error {
|
func (c *Content) String(content []byte) error {
|
||||||
doc, err := xmlquery.Parse(
|
doc, err := xmlquery.Parse(
|
||||||
strings.NewReader(
|
strings.NewReader(
|
||||||
cleanentitles.ReplaceAllString(string(content), " ")))
|
cleansvg.ReplaceAllString(
|
||||||
|
cleanentitles.ReplaceAllString(string(content), " "), "")))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user