mirror of https://github.com/mindoc-org/mindoc.git
parent
95408e4b0d
commit
bf1b38a36e
|
@ -615,9 +615,9 @@ func (book *Book) ImportBook(zipPath string) error {
|
||||||
|
|
||||||
filetil.CopyFile(linkPath, dstPath)
|
filetil.CopyFile(linkPath, dstPath)
|
||||||
|
|
||||||
tempLink := strings.TrimPrefix(strings.Replace(dstPath, "\\", "/", -1), strings.Replace(conf.WorkingDirectory, "\\", "/", -1))
|
tempLink := conf.BaseUrl + strings.TrimPrefix(strings.Replace(dstPath, "\\", "/", -1), strings.Replace(conf.WorkingDirectory, "\\", "/", -1))
|
||||||
|
|
||||||
link = strings.TrimSuffix(tempLink, originalLink+")") + link + ")"
|
link = strings.TrimSuffix(link, originalLink+")") + tempLink + ")"
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -451,12 +451,13 @@ func exportMarkdown(p string, parentId int, bookId int,baseDir string) error {
|
||||||
dirPath := filepath.Dir(docPath)
|
dirPath := filepath.Dir(docPath)
|
||||||
|
|
||||||
os.MkdirAll(dirPath, 0766)
|
os.MkdirAll(dirPath, 0766)
|
||||||
|
markdown := doc.Markdown
|
||||||
|
//如果当前文档不为空
|
||||||
|
if strings.TrimSpace(doc.Markdown) != "" {
|
||||||
re := regexp.MustCompile(`!\[(.*?)\]\((.*?)\)`)
|
re := regexp.MustCompile(`!\[(.*?)\]\((.*?)\)`)
|
||||||
|
|
||||||
//处理文档中图片
|
//处理文档中图片
|
||||||
markdown := re.ReplaceAllStringFunc(doc.Markdown, func(image string) string {
|
markdown = re.ReplaceAllStringFunc(doc.Markdown, func(image string) string {
|
||||||
images := re.FindAllSubmatch([]byte(image), -1)
|
images := re.FindAllSubmatch([]byte(image), -1)
|
||||||
if len(images) <= 0 || len(images[0]) < 3 {
|
if len(images) <= 0 || len(images[0]) < 3 {
|
||||||
return image
|
return image
|
||||||
|
@ -498,6 +499,9 @@ func exportMarkdown(p string, parentId int, bookId int,baseDir string) error {
|
||||||
return link
|
return link
|
||||||
|
|
||||||
})
|
})
|
||||||
|
}else{
|
||||||
|
markdown = "# " + doc.DocumentName + "\n"
|
||||||
|
}
|
||||||
if err := ioutil.WriteFile(docPath, []byte(markdown), 0644); err != nil {
|
if err := ioutil.WriteFile(docPath, []byte(markdown), 0644); err != nil {
|
||||||
beego.Error("导出Markdown失败=>", err)
|
beego.Error("导出Markdown失败=>", err)
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in New Issue