walles / moar

Moar is a pager. It's designed to just do the right thing without any configuration.
Other
587 stars 17 forks source link

Perl syntax for perldoc #110

Closed ZaxonXP closed 1 year ago

ZaxonXP commented 1 year ago

I tried to display Perl documentation using perldoc perldsc, but I do not have a Perl code syntax highlighted. On the other hand when using moar with perl script, then the syntax is shown correctly. How to force perldoc output to highlight the code?

Regards, Piotr

walles commented 1 year ago

Hello Piotr!

I did this and it got me some highlighting:

perldoc -M Pod::Perldoc::ToANSI perldsc

Here's a list of what I think are all supported formatters: https://metacpan.org/dist/Pod-Perldoc

What this does is that it makes perldoc add ANSI SGR codes to its output which moar then renders accordingly.

Does this solve your problem?

Regards /Johan

ZaxonXP commented 1 year ago

It is one way to use it. Thanks!

In a meantime I found a workaround:

#!/bin/sh
# file 'pdoc'
tmp=$(mktemp).pl
perldoc $1 > $tmp
moar $tmp
rm $tmp

So moar will open *.pl files correctly, which is what I wanted. :)