Skip to content

Commit eec674c

Browse files
Fix tag validation: only remove actual valid tags, preserve inline code
- Replace broad regex pattern with precise isValidTag() validation - Preserve legitimate inline code like [1], [gin], net/http - Remove unused regexp import - Ensure only approved tags ([lib], [app], [active], [stalled], [unmaintained]) are removed
1 parent 4adc3f9 commit eec674c

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

main.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"net/url"
1010
"os"
1111
"path/filepath"
12-
"regexp"
1312
"strings"
1413
"text/template"
1514

@@ -288,12 +287,11 @@ func extractCategory(doc *goquery.Document, selector string) (*Category, error)
288287
}
289288
})
290289

291-
// Remove only code elements that match tag pattern, preserve inline code like `net/http`
290+
// Remove only code elements that are valid tags, preserve inline code like `net/http`, `[1]`, `[gin]`
292291
clonedLi := selLi.Clone()
293-
tagPattern := regexp.MustCompile(`^\[.+\]$`)
294292
clonedLi.Find("code").Each(func(i int, codeEl *goquery.Selection) {
295293
codeText := strings.TrimSpace(codeEl.Text())
296-
if tagPattern.MatchString(codeText) {
294+
if isValidTag(codeText) {
297295
codeEl.Remove()
298296
}
299297
})

0 commit comments

Comments
 (0)