Skip to content

Commit b50de5f

Browse files
committed
refactor: collapse isFlagBoundaryChar into a single switch
1 parent bb3f686 commit b50de5f

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

internal/docgen/mintlify.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -189,16 +189,13 @@ func backtickFlags(s string) string {
189189
return strings.Join(parts, "```")
190190
}
191191

192+
// isFlagBoundaryChar reports whether c is a valid character before a flag —
193+
// anything that is not a word char (\w), backtick, slash, or dash.
192194
func isFlagBoundaryChar(c byte) bool {
193-
// A flag must be preceded by start-of-string or a character that is not
194-
// a word char, slash, dash, or backtick.
195-
if c == '/' || c == '-' || c == '`' {
195+
switch {
196+
case c == '/', c == '-', c == '`', c == '_':
196197
return false
197-
}
198-
if c == '_' {
199-
return false
200-
}
201-
if (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') {
198+
case c >= 'a' && c <= 'z', c >= 'A' && c <= 'Z', c >= '0' && c <= '9':
202199
return false
203200
}
204201
return true

0 commit comments

Comments
 (0)