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 {
var (
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.WithHardWraps(),
}
)
} else {
opts = []renderer.Option{
html.WithXHTML(),
html.WithHardWraps(),
if !basic {
// Allow raw HTML. We sanitize
// at the end so this is OK.
rendererOptions = append(
rendererOptions,
// Allow raw HTML tags, we
// sanitize at the end anyway.
html.WithUnsafe(),
)
}
}
// Instantiate goldmark parser for
@ -117,7 +123,7 @@ func (f *Formatter) fromMarkdown(
// to add hashtag/mention links.
md := goldmark.New(
goldmark.WithRendererOptions(
rendererOptions...,
opts...,
),
goldmark.WithExtensions(
&customRenderer{