in img path switched assets with static

This commit is contained in:
Lorenz Hohermuth 2024-05-03 20:11:47 +02:00
parent 9c7e309ec6
commit c8c1155fb8
1 changed files with 9 additions and 1 deletions
internal/mdparser

View File

@ -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