From c8c1155fb8609220ab7c0071853ec3cbd89882f9 Mon Sep 17 00:00:00 2001 From: lorenzhohermuth Date: Fri, 3 May 2024 20:11:47 +0200 Subject: [PATCH] in img path switched assets with static --- internal/mdparser/mdparser.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/internal/mdparser/mdparser.go b/internal/mdparser/mdparser.go index e1c743e..7e894c0 100644 --- a/internal/mdparser/mdparser.go +++ b/internal/mdparser/mdparser.go @@ -2,6 +2,7 @@ package mdparser import ( "context" + "fmt" "regexp" "strings" @@ -60,7 +61,14 @@ func parseMd(line string, title *string, text *string, img *string) (bool, compo } else if char == "!" { rgx := regexp.MustCompile(`\((.*?)\)`) - *img = rgx.FindStringSubmatch(line)[1] + mdImage := rgx.FindStringSubmatch(line)[1] + mdImage = strings.TrimSpace(mdImage) + + if mdImage[:4] != "http" { + mdImage = strings.Replace(mdImage, "assets", "static", 1) + } + + *img = mdImage } else { *text += line