diff --git a/ebook/build.go b/ebook/build.go index 564fe205..fbf7e662 100644 --- a/ebook/build.go +++ b/ebook/build.go @@ -2,12 +2,13 @@ package main import ( "fmt" - "github.com/fairlyblank/md2min" "io/ioutil" "os" "path/filepath" "regexp" "strings" + + "github.com/fairlyblank/md2min" ) // 定义一个访问者结构体 @@ -50,6 +51,9 @@ func (self *Visitor) md2html(arg map[string]string) error { // 删除页面链接 input = RemoveFooterLink(input) + // remove image suffix + input = RemoveImageLinkSuffix(input) + var out *os.File filename := strings.Replace(f.Name(), ".md", ".html", -1) fmt.Println(to + "/" + filename) @@ -85,6 +89,11 @@ func RemoveFooterLink(input string) string { return re_footer.ReplaceAllString(input, "") } +func RemoveImageLinkSuffix(input string) string { + re_footer := regexp.MustCompile(`png\?raw=true`) + return re_footer.ReplaceAllString(input, "png") +} + func main() { tmp := os.Getenv("TMP") if tmp == "" {