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,19 +189,13 @@ func backtickFlags(s string) string {
189189 return strings .Join (parts , "```" )
190190}
191191
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.
192197func 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 == '`' {
196- return false
197- }
198- if c == '_' {
199- return false
200- }
201- if (c >= 'a' && c <= 'z' ) || (c >= 'A' && c <= 'Z' ) || (c >= '0' && c <= '9' ) {
202- return false
203- }
204- return true
198+ return ! nonBoundaryByte .Match ([]byte {c })
205199}
206200
207201func backtickFlagsFragment (s string ) string {
You can’t perform that action at this time.
0 commit comments