diff options
author | Brian Picciano <mediocregopher@gmail.com> | 2022-05-21 13:54:14 -0600 |
---|---|---|
committer | Brian Picciano <mediocregopher@gmail.com> | 2022-05-21 13:54:14 -0600 |
commit | 7335295dc0e6470abdbc6860ac567db76f4859fc (patch) | |
tree | ac4248542f1f8de29a4a08293cf33cc96a31285f | |
parent | b136b42a4421745b41a4535fb86ace1e64c4ff93 (diff) |
Fix rendering errors near script tags
-rw-r--r-- | srv/src/http/posts.go | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/srv/src/http/posts.go b/srv/src/http/posts.go index 432a1e1..71f30ab 100644 --- a/srv/src/http/posts.go +++ b/srv/src/http/posts.go @@ -66,14 +66,19 @@ func (a *api) postToPostTplPayload(storedPost post.StoredPost) (postTplPayload, } bodyBuf := new(bytes.Buffer) + if err := bodyTpl.Execute(bodyBuf, nil); err != nil { return postTplPayload{}, fmt.Errorf("executing post body as template: %w", err) } + // this helps the markdown renderer properly parse pages which end in a + // `</script>` tag... I don't know why. + _, _ = bodyBuf.WriteString("\n") + parserExt := parser.CommonExtensions | parser.AutoHeadingIDs parser := parser.NewWithExtensions(parserExt) - htmlFlags := html.CommonFlags | html.HrefTargetBlank + htmlFlags := html.HrefTargetBlank htmlRenderer := html.NewRenderer(html.RendererOptions{Flags: htmlFlags}) renderedBody := markdown.ToHTML(bodyBuf.Bytes(), parser, htmlRenderer) |