jiggle the opts

This commit is contained in:
tobi 2025-03-07 11:43:16 +01:00
commit 2497a4d596

View file

@ -97,19 +97,25 @@ func (f *Formatter) fromMarkdown(
) *FormatResult { ) *FormatResult {
var ( var (
result = new(FormatResult) result = new(FormatResult)
rendererOptions = []renderer.Option{ opts []renderer.Option
)
if basic {
// Don't allow raw HTML tags,
// markdown syntax only.
opts = []renderer.Option{
html.WithXHTML(), html.WithXHTML(),
html.WithHardWraps(), html.WithHardWraps(),
} }
) } else {
opts = []renderer.Option{
html.WithXHTML(),
html.WithHardWraps(),
if !basic { // Allow raw HTML tags, we
// Allow raw HTML. We sanitize // sanitize at the end anyway.
// at the end so this is OK.
rendererOptions = append(
rendererOptions,
html.WithUnsafe(), html.WithUnsafe(),
) }
} }
// Instantiate goldmark parser for // Instantiate goldmark parser for
@ -117,7 +123,7 @@ func (f *Formatter) fromMarkdown(
// to add hashtag/mention links. // to add hashtag/mention links.
md := goldmark.New( md := goldmark.New(
goldmark.WithRendererOptions( goldmark.WithRendererOptions(
rendererOptions..., opts...,
), ),
goldmark.WithExtensions( goldmark.WithExtensions(
&customRenderer{ &customRenderer{