summaryrefslogtreecommitdiff
path: root/srv/src
diff options
context:
space:
mode:
authorBrian Picciano <mediocregopher@gmail.com>2022-05-21 13:54:14 -0600
committerBrian Picciano <mediocregopher@gmail.com>2022-05-21 13:54:14 -0600
commit7335295dc0e6470abdbc6860ac567db76f4859fc (patch)
treeac4248542f1f8de29a4a08293cf33cc96a31285f /srv/src
parentb136b42a4421745b41a4535fb86ace1e64c4ff93 (diff)
Fix rendering errors near script tags
Diffstat (limited to 'srv/src')
-rw-r--r--srv/src/http/posts.go7
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)