Use json.RawMessage for document data content
Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
@@ -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("")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user