From 54a0af34fb7a0c6a7cfb6d2712ec23a25eed4509 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?nicole=20miko=C5=82ajczyk?= Date: Mon, 9 Jun 2025 16:00:25 +0200 Subject: [PATCH] [feature] enable footnote extension for markdown parser (#4251) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: nicole mikołajczyk # Description This enables footnote support which is mentioned as allowed in the [user guide](https://codeberg.org/superseriousbusiness/gotosocial/src/branch/main/docs/user_guide/posts.md#input-types). The regression was reported on Matrix. ## Checklist Please put an x inside each checkbox to indicate that you've read and followed it: `[ ]` -> `[x]` If this is a documentation change, only the first checkbox must be filled (you can delete the others if you want). - [x] I/we have read the [GoToSocial contribution guidelines](https://codeberg.org/superseriousbusiness/gotosocial/src/branch/main/CONTRIBUTING.md). - [sort of] I/we have discussed the proposed changes already, either in an issue on the repository, or in the Matrix chat. - [x] I/we have not leveraged AI to create the proposed changes. - [x] I/we have performed a self-review of added code. - [x] I/we have written code that is legible and maintainable by others. - [ ] I/we have commented the added code, particularly in hard-to-understand areas. - [ ] I/we have made any necessary changes to documentation. - [x] I/we have added tests that cover new code. - [x] I/we have run tests and they pass locally with the changes. - [x] I/we have run `go fmt ./...` and `golangci-lint run`. Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4251 Co-authored-by: nicole mikołajczyk Co-committed-by: nicole mikołajczyk --- internal/text/markdown.go | 1 + internal/text/markdown_test.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/text/markdown.go b/internal/text/markdown.go index a26182598..e4b633e75 100644 --- a/internal/text/markdown.go +++ b/internal/text/markdown.go @@ -141,6 +141,7 @@ func (f *Formatter) fromMarkdown( extension.NewLinkify( extension.WithLinkifyURLRegexp(regexes.URLLike), ), + extension.Footnote, extension.Strikethrough, ), ) diff --git a/internal/text/markdown_test.go b/internal/text/markdown_test.go index 5048fab87..347ca2928 100644 --- a/internal/text/markdown_test.go +++ b/internal/text/markdown_test.go @@ -61,7 +61,7 @@ const ( mdCodeBlockWithNewlines = "some code coming up\n\n```\n\n\n\n```\nthat was some code" mdCodeBlockWithNewlinesExpected = "

some code coming up

\n\n\n

that was some code

" mdWithFootnote = "fox mulder,fbi.[^1]\n\n[^1]: federated bureau of investigation" - mdWithFootnoteExpected = "

fox mulder,fbi.[^1]

[^1]: federated bureau of investigation

" + mdWithFootnoteExpected = "

fox mulder,fbi.1


  1. federated bureau of investigation ↩︎

" mdWithBlockQuote = "get ready, there's a block quote coming:\n\n>line1\n>line2\n>\n>line3\n\n" mdWithBlockQuoteExpected = "

get ready, there's a block quote coming:

line1
line2

line3

" mdHashtagAndCodeBlock = "#Hashtag\n\n```\n#Hashtag\n```"