From 4bb26fbf9570de750e1236922b1ca9dafc10b50b Mon Sep 17 00:00:00 2001 From: Trevor Slocum Date: Mon, 9 Feb 2026 22:13:03 -0800 Subject: [PATCH] Add Raw field to HTMLTag When Raw is enabled, the content of HTMLTag is not escaped. --- go.mod | 3 +++ html.go | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 go.mod diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..99f04eb --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module github.com/frustra/bbcode + +go 1.24.9 diff --git a/html.go b/html.go index 6bd7fdd..e96fc20 100644 --- a/html.go +++ b/html.go @@ -15,6 +15,7 @@ import ( type HTMLTag struct { Name string Value string + Raw bool Attrs map[string]string Children []*HTMLTag } @@ -35,9 +36,9 @@ func (t *HTMLTag) String() string { // The html representation of the tag with or without sorted arguments. func (t *HTMLTag) Compile(sorted bool) string { - var value string - if len(t.Value) > 0 { - value = html.EscapeString(t.Value) + value := t.Value + if !t.Raw && len(value) > 0 { + value = html.EscapeString(value) } var attrString string