Reformat links as well

This commit is contained in:
Steve Streeting 2015-09-17 11:36:07 +01:00
parent 84a3ef96ba
commit 625f4a991d

@ -33,6 +33,8 @@ func main() {
out.WriteString("// Use 'go generate ./commands' to update\n")
fileregex := regexp.MustCompile(`git-lfs(?:-([A-Za-z\-]+))?.\d.ronn`)
headerregex := regexp.MustCompile(`^###?\s+([A-Za-z0-9 ]+)`)
// only pick up caps in links to avoid matching optional args
linkregex := regexp.MustCompile(`\[([A-Z\- ]+)\]`)
count := 0
for _, f := range fs {
if match := fileregex.FindStringSubmatch(f.Name()); match != nil {
@ -85,6 +87,11 @@ func main() {
firstHeaderDone = true
lastLineWasBullet = false
continue
} else if lmatches := linkregex.FindAllStringSubmatch(line, -1); lmatches != nil {
for _, lmatch := range lmatches {
linktext := strings.ToLower(lmatch[1])
line = strings.Replace(line, lmatch[0], `"`+strings.ToUpper(linktext[:1])+linktext[1:]+`"`, 1)
}
}
// Skip content until after first header
if !firstHeaderDone {