优化导出Markdown内链路径

pull/244/head v0.10
Minho 2018-03-27 02:59:04 +08:00
parent be7a64e03e
commit 07e424474e
1 changed files with 8 additions and 0 deletions

View File

@ -523,6 +523,14 @@ func exportMarkdown(p string, parentId int, bookId int,baseDir string,bookUrl st
if !strings.HasSuffix(tempLink,".md") && !strings.HasSuffix(doc.Identify,".markdown") { if !strings.HasSuffix(tempLink,".md") && !strings.HasSuffix(doc.Identify,".markdown") {
tempLink = tempLink + ".md" tempLink = tempLink + ".md"
} }
relative := strings.TrimPrefix(strings.Replace(p,"\\","/",-1),strings.Replace(baseDir,"\\","/",-1))
repeat := 0
if relative != "" {
relative = strings.TrimSuffix(strings.TrimPrefix(relative,"/"),"/")
repeat = strings.Count(relative,"/") + 1
}
beego.Info(repeat,"|",relative,"|",p,"|",baseDir)
tempLink = strings.Repeat("../",repeat) + tempLink
link = strings.TrimSuffix(link, originalLink+")") + tempLink + ")" link = strings.TrimSuffix(link, originalLink+")") + tempLink + ")"
} }