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

Created on 21 Sep 2017  路  7Comments  路  Source: github/linguist

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!

Most helpful comment

Fix is now live.

All 7 comments

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:

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.

/cc @kivikakk

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.

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

Fix is now live.

Thank you!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

etc0de picture etc0de  路  5Comments

oldmud0 picture oldmud0  路  6Comments

Sanchez3 picture Sanchez3  路  4Comments

haskellcamargo picture haskellcamargo  路  3Comments

lucasrodes picture lucasrodes  路  6Comments