From b56aa166416d544eccd17050da0dc2a720efc3e8 Mon Sep 17 00:00:00 2001 From: aichy126 <16996097+aichy126@users.noreply.github.com> Date: Wed, 26 Apr 2023 18:11:26 +0800 Subject: [PATCH] update makdown kbd --- pkg/converter/markdown.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/converter/markdown.go b/pkg/converter/markdown.go index ffc8d9e8..17deb990 100644 --- a/pkg/converter/markdown.go +++ b/pkg/converter/markdown.go @@ -38,6 +38,7 @@ func Markdown2HTML(source string) string { filter.RequireNoFollowOnLinks(false) filter.RequireParseableURLs(false) filter.RequireNoFollowOnFullyQualifiedLinks(false) + filter.AllowElements("kbd") html = filter.Sanitize(html) return html } @@ -87,7 +88,11 @@ func (r *DangerousHTMLRenderer) renderRawHTML(w util.BufWriter, source []byte, n l := n.Segments.Len() for i := 0; i < l; i++ { segment := n.Segments.At(i) - _, _ = w.Write(r.Filter.SanitizeBytes(segment.Value(source))) + if string(source[segment.Start:segment.Stop]) == "" || string(source[segment.Start:segment.Stop]) == "" { + _, _ = w.Write(segment.Value(source)) + } else { + _, _ = w.Write(r.Filter.SanitizeBytes(segment.Value(source))) + } } return ast.WalkSkipChildren, nil }