File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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.
192+ // nonBoundaryByte matches a single byte that cannot precede a CLI flag:
193+ // a word char (\w), backtick, slash, or dash.
194+ var nonBoundaryByte = regexp .MustCompile ("[`/\\ w-]" )
195+
196+ // isFlagBoundaryChar reports whether c is a valid character before a flag.
194197func isFlagBoundaryChar (c byte ) bool {
195- switch {
196- case c == '/' , c == '-' , c == '`' , c == '_' :
197- return false
198- case c >= 'a' && c <= 'z' , c >= 'A' && c <= 'Z' , c >= '0' && c <= '9' :
199- return false
200- }
201- return true
198+ return ! nonBoundaryByte .Match ([]byte {c })
202199}
203200
204201func backtickFlagsFragment (s string ) string {
You can’t perform that action at this time.
0 commit comments