兼容Markdown导入特殊的链接

pull/358/head
lifei6671 2018-07-23 14:38:33 +08:00
parent d7186ff270
commit 1eae95ea5d
1 changed files with 10 additions and 4 deletions

View File

@ -715,12 +715,18 @@ func (book *Book) ImportBook(zipPath string) error {
originalLink := links[0][2]
var linkPath string
var err error
if strings.HasPrefix(originalLink,"<") {
originalLink = strings.TrimPrefix(originalLink,"<")
}
if strings.HasSuffix(originalLink,">") {
originalLink = strings.TrimSuffix(originalLink,">")
}
//如果是从根目录开始,
if strings.HasPrefix(originalLink,"/") {
linkPath,err = filepath.Abs(filepath.Join(tempPath,originalLink))
}else if strings.HasPrefix(originalLink, "./"){
if strings.HasPrefix(originalLink, "/") {
linkPath, err = filepath.Abs(filepath.Join(tempPath, originalLink))
} else if strings.HasPrefix(originalLink, "./") {
linkPath, err = filepath.Abs(filepath.Join(filepath.Dir(path), originalLink[1:]))
}else{
} else{
linkPath, err = filepath.Abs(filepath.Join(filepath.Dir(path), originalLink))
}