Use json.RawMessage for document data content

Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
Émile Ré
2026-03-30 11:28:27 +04:00
parent f29b9e22d3
commit be189693ae
4 changed files with 59 additions and 47 deletions

View File

@@ -17,6 +17,7 @@ package docgen
import (
"bytes"
_ "embed"
"encoding/json"
"fmt"
"html"
"html/template"
@@ -194,7 +195,7 @@ type (
DocumentData struct {
Title string
Content string // ProseMirror/Tiptap document JSON; use ProseMirrorJSONToHTML for HTML
Content json.RawMessage // ProseMirror/Tiptap document JSON; use ProseMirrorJSONToHTML for HTML
Major int
Minor int
Classification Classification
@@ -319,8 +320,8 @@ const (
// ProseMirrorJSONToHTML converts ProseMirror/Tiptap document JSON to an HTML fragment.
// On parse or render failure it returns a single escaped paragraph with the raw input.
func ProseMirrorJSONToHTML(content string) template.HTML {
s := strings.TrimSpace(content)
func ProseMirrorJSONToHTML(content json.RawMessage) template.HTML {
s := strings.TrimSpace(string(content))
if s == "" {
return template.HTML("")
}