From 0bec3c3eef6340d0d73310b412aeb1d0a11e4a69 Mon Sep 17 00:00:00 2001 From: Aaron Fischer Date: Fri, 9 Jul 2021 22:45:52 +0200 Subject: [PATCH] Fix wrong package name and clean up tag-building DRY the tag building for links and images. --- config.go | 2 +- pkg/gmitohtml/convert.go | 18 ++++++------------ 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/config.go b/config.go index aa8ca70..5d26292 100644 --- a/config.go +++ b/config.go @@ -1,4 +1,4 @@ -package gmitohtml +package main import ( "crypto/tls" diff --git a/pkg/gmitohtml/convert.go b/pkg/gmitohtml/convert.go index 59588be..fcaf208 100644 --- a/pkg/gmitohtml/convert.go +++ b/pkg/gmitohtml/convert.go @@ -128,7 +128,6 @@ func Convert(page []byte, u string) []byte { linkLabel = line[splitStart:] } - // If link ends with gif/png/jpg, add a image instead of a link parts := strings.Split(string(linkURL), ".") extension := parts[len(parts)-1] isImage := false @@ -138,19 +137,14 @@ func Convert(page []byte, u string) []byte { } } + uri := html.EscapeString(rewriteURL(string(linkURL), parsedURL)) + title := html.EscapeString(string(linkLabel)) + + // If link ends with gif/png/jpg, add a image instead of a link if isImage && Config.ConvertImages { - img := append([]byte(``)...)
-				img = append(img, html.EscapeString(string(linkLabel))...)
-				img = append(img, []byte(``)...) - result = append(result, img...) + result = append(result, []byte("\""")...) } else { - link := append([]byte(``)...) - link = append(link, html.EscapeString(string(linkLabel))...) - link = append(link, []byte(``)...) - result = append(result, link...) - result = append(result, []byte("
")...) + result = append(result, []byte("" + title + "
")...) } continue