From 625f4a991d027bbec3d372efe5a034ef7163d988 Mon Sep 17 00:00:00 2001 From: Steve Streeting Date: Thu, 17 Sep 2015 11:36:07 +0100 Subject: [PATCH] Reformat links as well --- docs/man/mangen.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/man/mangen.go b/docs/man/mangen.go index 6cc800e5..1c636d1d 100644 --- a/docs/man/mangen.go +++ b/docs/man/mangen.go @@ -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 {