summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar nicole mikołajczyk <git@mkljczk.pl>2025-06-09 16:00:25 +0200
committerLibravatar tobi <kipvandenbos@noreply.codeberg.org>2025-06-09 16:00:25 +0200
commit54a0af34fb7a0c6a7cfb6d2712ec23a25eed4509 (patch)
treef6dde537b7c3eaf44a26defd29dd4082d86ee714
parent[docs] change ID links in ToC to match goldmark parser behavior (#4223) (diff)
downloadgotosocial-54a0af34fb7a0c6a7cfb6d2712ec23a25eed4509.tar.xz
[feature] enable footnote extension for markdown parser (#4251)
Signed-off-by: nicole mikołajczyk <git@mkljczk.pl> # 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 <git@mkljczk.pl> Co-committed-by: nicole mikołajczyk <git@mkljczk.pl>
-rw-r--r--internal/text/markdown.go1
-rw-r--r--internal/text/markdown_test.go2
2 files changed, 2 insertions, 1 deletions
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 = "<p>some code coming up</p><pre><code>\n\n\n</code></pre><p>that was some code</p>"
mdWithFootnote = "fox mulder,fbi.[^1]\n\n[^1]: federated bureau of investigation"
- mdWithFootnoteExpected = "<p>fox mulder,fbi.[^1]</p><p>[^1]: federated bureau of investigation</p>"
+ mdWithFootnoteExpected = "<p>fox mulder,fbi.<sup id=\"fnref:1\"><a class=\"footnote-ref\">1</a></sup></p><div><hr><ol><li id=\"fn:1\"><p>federated bureau of investigation <a class=\"footnote-backref\">↩︎</a></p></li></ol></div>"
mdWithBlockQuote = "get ready, there's a block quote coming:\n\n>line1\n>line2\n>\n>line3\n\n"
mdWithBlockQuoteExpected = "<p>get ready, there's a block quote coming:</p><blockquote><p>line1<br>line2</p><p>line3</p></blockquote>"
mdHashtagAndCodeBlock = "#Hashtag\n\n```\n#Hashtag\n```"