diff --git a/post.go b/post.go
index f91b9b4..d6bc658 100644
--- a/post.go
+++ b/post.go
@@ -8,6 +8,7 @@ import (
"github.com/yuin/goldmark"
"github.com/yuin/goldmark/extension"
"github.com/yuin/goldmark/parser"
+ "github.com/yuin/goldmark/renderer/html"
"gopkg.in/yaml.v2"
)
@@ -80,7 +81,15 @@ func (post Post) MarkdownData() (bytes.Buffer, PostMeta) {
}
}
+ options := goldmark.WithRendererOptions()
+ if post.user.repo.AllowRawHtml() {
+ options = goldmark.WithRendererOptions(
+ html.WithUnsafe(),
+ )
+ }
+
markdown := goldmark.New(
+ options,
goldmark.WithExtensions(
// meta.Meta,
extension.GFM,
diff --git a/post_test.go b/post_test.go
index a7661b8..83ee19d 100644
--- a/post_test.go
+++ b/post_test.go
@@ -3,6 +3,7 @@ package owl_test
import (
"os"
"path"
+ "strings"
"testing"
)
@@ -84,3 +85,40 @@ func TestDraftInMetaData(t *testing.T) {
}
}
+
+func TestNoRawHTMLIfDisallowedByRepo(t *testing.T) {
+ repo := getTestRepo()
+ user, _ := repo.CreateUser("testuser")
+ post, _ := user.CreateNewPost("testpost")
+ content := "---\n"
+ content += "title: test\n"
+ content += "draft: true\n"
+ content += "---\n"
+ content += "\n"
+ content += "\n"
+ os.WriteFile(post.ContentFile(), []byte(content), 0644)
+ html, _ := post.MarkdownData()
+ html_str := html.String()
+ if strings.Contains(html_str, "\n"
+ os.WriteFile(post.ContentFile(), []byte(content), 0644)
+ html, _ := post.MarkdownData()
+ html_str := html.String()
+ if !strings.Contains(html_str, "