kristopolous / mansnip

📺 "The new way to search through manpages that everyone is talking about!"
MIT License
68 stars 4 forks source link

Fix regexp strings #10

Closed elig0n closed 1 month ago

elig0n commented 4 months ago

improperly quoted regex pattern strings induce warnings when run:

mansnip:59: SyntaxWarning: invalid escape sequence '\s'
  '^\s*',
mansnip:62: SyntaxWarning: invalid escape sequence '\+'
  '(\+\||)',
mansnip:69: SyntaxWarning: invalid escape sequence '\s'
  '([\s_\[=].*|, .*|)',
mansnip:76: SyntaxWarning: invalid escape sequence '\s'
  '([\s_\[=].*|)',
mansnip:84: SyntaxWarning: invalid escape sequence '\s'
  getopts_simple_re = '^\s+(-{1,2}\w+\s?\w*)+\s*$'
mansnip:112: SyntaxWarning: invalid escape sequence '\['
  clean_ansi = lambda w: re.sub('(.\x08|\x1B\[\d*m)', '', w)
mansnip:148: SyntaxWarning: invalid escape sequence '\s'
  indent = re.match('^(\s*)', line).end()
mansnip:324: SyntaxWarning: invalid escape sequence '\s'
  buf[0] = re.sub('^\s{%d}' % rs, '', buf[0])

(tested with python 3.12)

kristopolous commented 1 month ago

My notifications window is a flood of garbage. Sorry I don't see these. Let me try this out.

kristopolous commented 1 month ago

behavior confirmed with 3.12.1. Checking your fix now.

kristopolous commented 1 month ago

ok i tested it and the test behavior is identical. The tests are pretty out of date - not robust to man page updates. I should probably figure that out.

Thanks for the patch