From 35ed01b218225d1712c295729fd9fc334de1510b Mon Sep 17 00:00:00 2001 From: johnnyjoy Date: Sun, 14 Jul 2024 20:29:51 +0800 Subject: [PATCH] chore: update html element node renderer --- renderer/html/html.go | 6 ++++++ renderer/string/string.go | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/renderer/html/html.go b/renderer/html/html.go index e8ace60..ff0f4fd 100644 --- a/renderer/html/html.go +++ b/renderer/html/html.go @@ -85,6 +85,8 @@ func (r *HTMLRenderer) RenderNode(node ast.Node) { r.renderReferencedContent(n) case *ast.Spoiler: r.renderSpoiler(n) + case *ast.HTMLElement: + r.renderHTMLElement(n) default: // Handle other block types if needed. } @@ -341,3 +343,7 @@ func (r *HTMLRenderer) renderSpoiler(node *ast.Spoiler) { r.output.WriteString(node.Content) r.output.WriteString("") } + +func (r *HTMLRenderer) renderHTMLElement(node *ast.HTMLElement) { + r.output.WriteString(fmt.Sprintf("<%s >", node.TagName)) +} diff --git a/renderer/string/string.go b/renderer/string/string.go index 74f9c28..6a49ee5 100644 --- a/renderer/string/string.go +++ b/renderer/string/string.go @@ -85,6 +85,8 @@ func (r *StringRenderer) RenderNode(node ast.Node) { r.renderReferencedContent(n) case *ast.Spoiler: r.renderSpoiler(n) + case *ast.HTMLElement: + r.renderHTMLElement(n) default: // Handle other block types if needed. } @@ -246,3 +248,7 @@ func (*StringRenderer) renderReferencedContent(_ *ast.ReferencedContent) {} func (r *StringRenderer) renderSpoiler(node *ast.Spoiler) { r.output.WriteString(node.Content) } + +func (r *StringRenderer) renderHTMLElement(*ast.HTMLElement) { + r.output.WriteString("\n") +}