github-linguist / linguist

Language Savant. If your repository's language is being reported incorrectly, send us a pull request!
MIT License
12.23k stars 4.23k forks source link

perl files with no extension and POD and a shebang should be rendered as syntax-highlighted perl, not POD #3832

Closed dgholz closed 6 years ago

dgholz commented 7 years ago

This bug was introduced in #3735. Here's an expanded version of my comment from there.

This change recognizes files with no extension and a perl shebang and POD contents as POD files, but I'd expect them to be shown as syntax-highlighted perl. I would expect POD-only files to (maybe) have a .pod extension, and (always) no shebang. Some examples from CPAN:

https://metacpan.org/source/LEONT/Module-Build-0.4224/lib/Module/Build/API.pod has no shebang and a .pod extension.

https://metacpan.org/source/LEONT/Module-Build-0.4224/lib/Module/Build/Cookbook.pm has no shebang and a .pm extension.

Here's an example of where linguist chooses to render as POD rather than as syntax-highlighted perl: https://github.com/sitaramc/gitolite/blob/5c2fe87019dadbecb1883bedd075cd07b07b2078/src/gitolite It previously displayed as a highlighted perl script (good), but now displays as the embedded POD (requiring me to use the Raw view to be able to see the code). It has a shebang.

Please fix it to correctly detect these kinds of files as perl (not POD) or revert it, thanks!

biell commented 7 years ago

Change #3735 needs to be rolled-back. If a file starts with "#!/usr/bin/perl", "#!/usr/bin/env perl", or anything similar, then it should be rendered as perl code, not as pod. Rendering as code is the correct decision 99% of the time when a shebang is present, and so should be the default.

If you want to review the entire file and find no actual code, then you can render as pod. But, when in doubt, render as code when a shebang is present. This bug affects hundreds of repositories; including, but not limited to:

ascherer commented 7 years ago

Seconded. Please give priority to highlighted code over pod. IMHO, it's just plain wrong to display POD for an explicit #line reference into a Perl file; this should always display the (formatted) code.

lildude commented 7 years ago

/cc @kivikakk

omkensey commented 6 years ago

I spent some considerable time the other day looking for a Perl script in the spacewalk repo and seeing only what looked like a rendered README where it should be, thinking maybe somebody had committed over it accidentally, going back in time further and further. I stumbled on the idea of viewing it Raw purely by chance, and sure enough, there was the Perl code I'd been wanting all along.

kivikakk commented 6 years ago

Fix incoming. Sorry for such a long delay, all. :heart: (-> #3863)

kivikakk commented 6 years ago

Fix is now live.

dgholz commented 6 years ago

Thank you!