package main import ( "regexp" "strings" ) // StripAttachmentLinks finds links to the Resources/attachmenst folder // and replaces them with the filename. it'll only do this // when the line has `{{< figure` func StripAttachmentLinks(s string) string { if !strings.Contains(s, "{{< figure") { return s } var re = regexp.MustCompile(`(?m)\[\[Resources\/attachments\/(.*?)\]\]`) var substitution = `"$1"` return re.ReplaceAllString(s, substitution) }