From 1f2c78f86353d15b78837dabc26d4939a380c5bf Mon Sep 17 00:00:00 2001 From: jvoisin Date: Sun, 1 Dec 2024 14:16:00 +0100 Subject: [PATCH] Remove markdown support It was added in 2022 by #1513, to support blog.laravel.com, which has since switched to HTML. The Atom 0.3/1.0, RSS 1.0/2.0, RDF, and JSON formats don't support markdown in their spec, and any website serving it there should be considered as buggy and fixed. This shaves off 2MB from the miniflux binary, which is quite steep for a feature that nobody is/should be using, and remove a dependency which is always a good thing. --- go.mod | 1 - go.sum | 2 -- internal/reader/rewrite/rewrite_functions.go | 17 ----------------- internal/reader/rewrite/rewriter.go | 2 -- internal/reader/rewrite/rules.go | 2 -- 5 files changed, 24 deletions(-) diff --git a/go.mod b/go.mod index 54186ecb17a..b2a51d46a4e 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,6 @@ require ( github.com/lib/pq v1.10.9 github.com/prometheus/client_golang v1.20.5 github.com/tdewolff/minify/v2 v2.21.1 - github.com/yuin/goldmark v1.7.8 golang.org/x/crypto v0.29.0 golang.org/x/net v0.31.0 golang.org/x/oauth2 v0.24.0 diff --git a/go.sum b/go.sum index 6571924b78f..036c4d8a4af 100644 --- a/go.sum +++ b/go.sum @@ -66,8 +66,6 @@ github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcY github.com/xyproto/randomstring v1.0.5 h1:YtlWPoRdgMu3NZtP45drfy1GKoojuR7hmRcnhZqKjWU= github.com/xyproto/randomstring v1.0.5/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -github.com/yuin/goldmark v1.7.8 h1:iERMLn0/QJeHFhxSt3p6PeN9mGnvIKSpG9YYorDMnic= -github.com/yuin/goldmark v1.7.8/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.29.0 h1:L5SG1JTTXupVV3n6sUqMTeWbjAyfPwoda2DLX8J8FrQ= diff --git a/internal/reader/rewrite/rewrite_functions.go b/internal/reader/rewrite/rewrite_functions.go index 502d025cff5..7859003142a 100644 --- a/internal/reader/rewrite/rewrite_functions.go +++ b/internal/reader/rewrite/rewrite_functions.go @@ -17,8 +17,6 @@ import ( nethtml "golang.org/x/net/html" "github.com/PuerkitoBio/goquery" - "github.com/yuin/goldmark" - goldmarkhtml "github.com/yuin/goldmark/renderer/html" ) var ( @@ -410,21 +408,6 @@ func addHackerNewsLinksUsing(entryContent, app string) string { return entryContent } -func parseMarkdown(entryContent string) string { - var sb strings.Builder - md := goldmark.New( - goldmark.WithRendererOptions( - goldmarkhtml.WithUnsafe(), - ), - ) - - if err := md.Convert([]byte(entryContent), &sb); err != nil { - return entryContent - } - - return sb.String() -} - func removeTables(entryContent string) string { doc, err := goquery.NewDocumentFromReader(strings.NewReader(entryContent)) if err != nil { diff --git a/internal/reader/rewrite/rewriter.go b/internal/reader/rewrite/rewriter.go index b577f687517..8ce7dce0245 100644 --- a/internal/reader/rewrite/rewriter.go +++ b/internal/reader/rewrite/rewriter.go @@ -91,8 +91,6 @@ func (rule rule) applyRule(entryURL string, entry *model.Entry) { entry.Content = addHackerNewsLinksUsing(entry.Content, "hack") case "add_hn_links_using_opener": entry.Content = addHackerNewsLinksUsing(entry.Content, "opener") - case "parse_markdown": - entry.Content = parseMarkdown(entry.Content) case "remove_tables": entry.Content = removeTables(entry.Content) case "remove_clickbait": diff --git a/internal/reader/rewrite/rules.go b/internal/reader/rewrite/rules.go index 418f7db8d2d..89cba31daa2 100644 --- a/internal/reader/rewrite/rules.go +++ b/internal/reader/rewrite/rules.go @@ -12,7 +12,6 @@ var predefinedRules = map[string]string{ "abstrusegoose.com": "add_image_title", "amazingsuperpowers.com": "add_image_title", "blog.cloudflare.com": `add_image_title,remove("figure.kg-image-card figure.kg-image + img")`, - "blog.laravel.com": "parse_markdown", "cowbirdsinlove.com": "add_image_title", "drawingboardcomic.com": "add_image_title", "exocomics.com": "add_image_title", @@ -36,7 +35,6 @@ var predefinedRules = map[string]string{ "treelobsters.com": "add_image_title", "webtoons.com": `add_dynamic_image,replace("webtoon"|"swebtoon")`, "www.qwantz.com": "add_image_title,add_mailto_subject", - "www.recalbox.com": "parse_markdown", "xkcd.com": "add_image_title", "youtube.com": "add_youtube_video", }