commit bbdbda8cda8d035dfcafd8349767578f72151cb6
parent 00af87d7ff655867d5923818c7c4bea943e7e925
Author: alex wennerberg <alex@alexwennerberg.com>
Date: Sun, 31 Dec 2023 11:55:20 -0500
Disable MathJax from markdown
MathJax is rarely used and can cause surprising issues, such as:
"I want to spend between $5 and $10 on Apples"
ending up mangled
Diffstat:
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/util/util.go b/util/util.go
@@ -20,6 +20,7 @@ import (
"time"
"github.com/gomarkdown/markdown"
+ "github.com/gomarkdown/markdown/parser"
"github.com/komkom/toml"
"github.com/microcosm-cc/bluemonday"
"golang.org/x/exp/utf8string"
@@ -97,7 +98,8 @@ func Markup(md template.HTML) template.HTML {
mdBytes := []byte(string(md))
// fix newlines
mdBytes = markdown.NormalizeNewlines(mdBytes)
- maybeUnsafeHTML := markdown.ToHTML(mdBytes, nil, nil)
+ mdParser := parser.NewWithExtensions(parser.CommonExtensions ^ parser.MathJax)
+ maybeUnsafeHTML := markdown.ToHTML(mdBytes, mdParser, nil)
// guard against malicious code being embedded
html := contentGuardian.SanitizeBytes(maybeUnsafeHTML)
return template.HTML(html)