From 37ba97b1779b68fa19468c3140e7558063b47efd Mon Sep 17 00:00:00 2001 From: oppiliappan Date: Fri, 15 Aug 2025 17:21:22 +0100 Subject: [PATCH] appview/pages/markup: add footnot support Change-Id: kynwxqlsozuqnkmxtkqrsyuukovqnlqy Signed-off-by: oppiliappan --- appview/pages/markup/markdown.go | 3 +++ appview/pages/markup/sanitizer.go | 1 + input.css | 2 ++ 3 files changed, 6 insertions(+) diff --git a/appview/pages/markup/markdown.go b/appview/pages/markup/markdown.go index b00081a2..a3dfb155 100644 --- a/appview/pages/markup/markdown.go +++ b/appview/pages/markup/markdown.go @@ -56,6 +56,9 @@ func (rctx *RenderContext) RenderMarkdown(source string) string { ), highlighting.WithCustomStyle(styles.Get("catppuccin-latte")), ), + extension.NewFootnote( + extension.WithFootnoteIDPrefix([]byte("footnote")), + ), ), goldmark.WithParserOptions( parser.WithAutoHeadingID(), diff --git a/appview/pages/markup/sanitizer.go b/appview/pages/markup/sanitizer.go index 92696374..6ba27cc1 100644 --- a/appview/pages/markup/sanitizer.go +++ b/appview/pages/markup/sanitizer.go @@ -64,6 +64,7 @@ func defaultPolicy() *bluemonday.Policy { // for code blocks policy.AllowAttrs("class").Matching(regexp.MustCompile(`chroma`)).OnElements("pre") + policy.AllowAttrs("class").Matching(regexp.MustCompile(`anchor|footnote-ref|footnote-backref`)).OnElements("a") policy.AllowAttrs("class").Matching(regexp.MustCompile(strings.Join(slices.Collect(maps.Values(chroma.StandardTypes)), "|"))).OnElements("span") // centering content diff --git a/input.css b/input.css index a5261f43..33c70da7 100644 --- a/input.css +++ b/input.css @@ -136,6 +136,8 @@ .prose li:has(input) { list-style: none; + .prose a.footnote-backref { + @apply no-underline; } .prose li { -- 2.43.0