From 436bd3716f660ed7912f2a721a5d0a2e596c1a2d Mon Sep 17 00:00:00 2001 From: Virgil Date: Sat, 4 Apr 2026 01:59:54 +0000 Subject: [PATCH] fix(html): unescape stripped html entities Co-Authored-By: Virgil --- pipeline.go | 3 ++- pipeline_test.go | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pipeline.go b/pipeline.go index 3159b4f..e8c52ce 100644 --- a/pipeline.go +++ b/pipeline.go @@ -3,6 +3,7 @@ package html import ( + htmlstd "html" "strings" "unicode" @@ -48,7 +49,7 @@ func StripTags(html string) string { b.WriteRune(r) seenText = true } - return b.String() + return htmlstd.UnescapeString(b.String()) } // pipeline.go: Imprint renders a node tree to HTML, strips tags, tokenises the text, diff --git a/pipeline_test.go b/pipeline_test.go index 265b0e3..c8f0bec 100644 --- a/pipeline_test.go +++ b/pipeline_test.go @@ -55,10 +55,10 @@ func TestStripTags_NoTags(t *testing.T) { } func TestStripTags_Entities(t *testing.T) { - got := StripTags(`<script>`) - want := "<script>" + got := StripTags(`

& <script>

`) + want := "&