Merge pull request #348 from ngroup/master
fix issue with the missing images of the epub
This commit is contained in:
@@ -2,12 +2,13 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/fairlyblank/md2min"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/fairlyblank/md2min"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 定义一个访问者结构体
|
// 定义一个访问者结构体
|
||||||
@@ -50,6 +51,9 @@ func (self *Visitor) md2html(arg map[string]string) error {
|
|||||||
// 删除页面链接
|
// 删除页面链接
|
||||||
input = RemoveFooterLink(input)
|
input = RemoveFooterLink(input)
|
||||||
|
|
||||||
|
// remove image suffix
|
||||||
|
input = RemoveImageLinkSuffix(input)
|
||||||
|
|
||||||
var out *os.File
|
var out *os.File
|
||||||
filename := strings.Replace(f.Name(), ".md", ".html", -1)
|
filename := strings.Replace(f.Name(), ".md", ".html", -1)
|
||||||
fmt.Println(to + "/" + filename)
|
fmt.Println(to + "/" + filename)
|
||||||
@@ -85,6 +89,11 @@ func RemoveFooterLink(input string) string {
|
|||||||
return re_footer.ReplaceAllString(input, "")
|
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() {
|
func main() {
|
||||||
tmp := os.Getenv("TMP")
|
tmp := os.Getenv("TMP")
|
||||||
if tmp == "" {
|
if tmp == "" {
|
||||||
|
|||||||
Reference in New Issue
Block a user