You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
461 B
Go
20 lines
461 B
Go
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)
|
|
}
|