manly icon indicating copy to clipboard operation
manly copied to clipboard

manly crashes if manpage is not english

Open carlbordum opened this issue 5 years ago • 2 comments

Issue #30 made me realise that manly only works on english man pages. Luckily it appears to only be the case, because of the regex here https://github.com/carlbordum/manly/blob/master/manly.py#L154 that parses the title/NAME.

Currently it crashes with the rather cryptic error

Traceback (most recent call last):
  File "manly.py", line 191, in <module>
    main()
  File "manly.py", line 180, in main
    title, output = manly(args.command)
  File "manly.py", line 151, in manly
    re.search(r"(?<=^NAME\n\s{5}).+", manpage, re.MULTILINE).group(0).strip()
AttributeError: 'NoneType' object has no attribute 'group'

All ideas welcome. What are the different approaches to handle this?

carlbordum avatar Nov 29 '18 10:11 carlbordum

One approach could be to tell man to output english (setting env var LANG=C works, but maybe some other env var might be the preferred way). Then the output of manly will also be in english, but I guess most people prefer to read tech related things in english anyway?

Another alternative would be to first read the man page in english to find the correct location in it, then display the corresponding part of the non-english man page.

Akuli avatar May 18 '20 21:05 Akuli

I don't think we can count on translated man pages to have the same structure (either could have been reworked since the translation)

carlbordum avatar May 19 '20 14:05 carlbordum