in img path switched assets with static
This commit is contained in:
parent
9c7e309ec6
commit
c8c1155fb8
internal/mdparser
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue