fix missing images by removing the tailing part of the image paths on building the epub

This commit is contained in:
ngroup
2014-07-06 17:44:46 +08:00
parent b93a014729
commit f4c81571fd

View File

@@ -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 == "" {