Skip to content

Commit

Permalink
fix: bug with spacing (#397)
Browse files Browse the repository at this point in the history
Co-authored-by: GitHub Action <action@github.com>
  • Loading branch information
jackton1 and actions-user committed Dec 30, 2022
1 parent 51fd40f commit 1fe62c4
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 133 deletions.
2 changes: 1 addition & 1 deletion README.md
@@ -1,5 +1,5 @@
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/bb5dc10c1d2645c0894fa6774300639b)](https://app.codacy.com/gh/tj-actions/auto-doc?utm_source=github.com\&utm_medium=referral\&utm_content=tj-actions/auto-doc\&utm_campaign=Badge_Grade_Settings)
![Coverage](https://img.shields.io/badge/Coverage-82.4%25-brightgreen)
![Coverage](https://img.shields.io/badge/Coverage-82.2%25-brightgreen)
[![Go Reference](https://pkg.go.dev/badge/github.com/tj-actions/auto-doc.svg)](https://pkg.go.dev/github.com/tj-actions/auto-doc)
[![Go Report Card](https://goreportcard.com/badge/github.com/tj-actions/auto-doc)](https://goreportcard.com/report/github.com/tj-actions/auto-doc)
[![CI](https://github.com/tj-actions/auto-doc/workflows/CI/badge.svg)](https://github.com/tj-actions/auto-doc/actions?query=workflow%3ACI)
Expand Down
3 changes: 1 addition & 2 deletions cmd/root.go
Expand Up @@ -406,7 +406,6 @@ func wordWrap(s string, limit int) string {
// compile regular expressions for Markdown links and code blocks and code
linkRegex := regexp.MustCompile(`\[.*]\(.*\)`)
codeBlockRegex := regexp.MustCompile(`\` + "```" + `.*` + "```" + `\s*`)
codeRegex := regexp.MustCompile("`.*`")

// convert string to slice
strSlice := strings.Fields(s)
Expand All @@ -427,7 +426,7 @@ func wordWrap(s string, limit int) string {
if len(strSlice) < currentLimit {
currentLimit = len(strSlice)
result = result + strings.Join(strSlice[:currentLimit], " ")
} else if currentLimit == limit && !linkRegex.MatchString(strings.Join(strSlice[:currentLimit], " ")) && !codeBlockRegex.MatchString(strings.Join(strSlice[:currentLimit], " ")) && !codeRegex.MatchString(strings.Join(strSlice[:currentLimit], " ")) {
} else if currentLimit == limit && !linkRegex.MatchString(strings.Join(strSlice[:currentLimit], " ")) && !codeBlockRegex.MatchString(strings.Join(strSlice[:currentLimit], " ")) {
result = result + strings.Join(strSlice[:currentLimit], " ") + "<br>"
} else {
result = result + strings.Join(strSlice[:currentLimit], " ")
Expand Down

0 comments on commit 1fe62c4

Please sign in to comment.