From 7a6353a3b3d9c7c0a8cedf34c4aeb2eaacd2da79 Mon Sep 17 00:00:00 2001 From: Thomas von Dein Date: Tue, 21 Oct 2025 20:46:05 +0200 Subject: [PATCH] clean svg and cdata --- pkg/epub/content.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/epub/content.go b/pkg/epub/content.go index af2273d..8336b73 100644 --- a/pkg/epub/content.go +++ b/pkg/epub/content.go @@ -10,7 +10,8 @@ import ( var ( cleanentitles = regexp.MustCompile(`&[a-z]+;`) empty = regexp.MustCompile(`(?s)^[\s ]*$`) - newlines = regexp.MustCompile(`[\r\n]+`) + newlines = regexp.MustCompile(`[\r\n\s]+`) + cleansvg = regexp.MustCompile(`(|)`) cleanmarkup = regexp.MustCompile(`<[^<>]+>`) ) @@ -27,7 +28,8 @@ type Content struct { func (c *Content) String(content []byte) error { doc, err := xmlquery.Parse( strings.NewReader( - cleanentitles.ReplaceAllString(string(content), " "))) + cleansvg.ReplaceAllString( + cleanentitles.ReplaceAllString(string(content), " "), ""))) if err != nil { return err }