Skip to content

Commit c97ccae

Browse files
committed
Merge pull request astaxie#348 from ngroup/master
fix issue with the missing images of the epub
2 parents b93a014 + f4c8157 commit c97ccae

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

ebook/build.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ package main
22

33
import (
44
"fmt"
5-
"github.com/fairlyblank/md2min"
65
"io/ioutil"
76
"os"
87
"path/filepath"
98
"regexp"
109
"strings"
10+
11+
"github.com/fairlyblank/md2min"
1112
)
1213

1314
// 定义一个访问者结构体
@@ -50,6 +51,9 @@ func (self *Visitor) md2html(arg map[string]string) error {
5051
// 删除页面链接
5152
input = RemoveFooterLink(input)
5253

54+
// remove image suffix
55+
input = RemoveImageLinkSuffix(input)
56+
5357
var out *os.File
5458
filename := strings.Replace(f.Name(), ".md", ".html", -1)
5559
fmt.Println(to + "/" + filename)
@@ -85,6 +89,11 @@ func RemoveFooterLink(input string) string {
8589
return re_footer.ReplaceAllString(input, "")
8690
}
8791

92+
func RemoveImageLinkSuffix(input string) string {
93+
re_footer := regexp.MustCompile(`png\?raw=true`)
94+
return re_footer.ReplaceAllString(input, "png")
95+
}
96+
8897
func main() {
8998
tmp := os.Getenv("TMP")
9099
if tmp == "" {

0 commit comments

Comments
 (0)