http://qs321.pair.com?node_id=11136178

miguelnixon has asked for the wisdom of the Perl Monks concerning the following question:

Hi all: forgive me if this is the wrong forum, or the question has already been asked.
Linux Mint xfce 19.2 with Perl v5.22
A script with embedded pod renders correctly using "perldoc myfunc"
Linux Mint xfce 20 with Perl v5.30
Does not render Bold, Italics etc but just shows plain text using "perldoc myfunc".
Here is what output looks like (hexdump on mint 19.2, perl v5.22):
perldoc junk2|hexdump -C 00000000 1b 5b 31 6d 1b 5b 31 6d 68 65 61 64 69 6e 67 1b |.[1m.[1mh +eading.| 00000010 5b 30 6d 1b 5b 30 6d 0a 20 20 20 20 1b 5b 34 6d |[0m.[0m. + .[4m| 00000020 61 72 67 75 6d 65 6e 74 31 1b 5b 30 6d 0a 20 20 |argument1 +.[0m. | 00000030 20 20 20 20 20 20 44 65 73 63 72 69 70 74 69 6f | Des +criptio| 00000040 6e 20 6f 66 20 74 68 65 20 66 69 72 73 74 20 61 |n of the +first a| 00000050 72 67 75 6d 65 6e 74 2e 0a 0a 20 20 20 20 1b 5b |rgument.. +. .[| 00000060 34 6d 61 72 67 75 6d 65 6e 74 32 1b 5b 30 6d 0a |4margumen +t2.[0m.| 00000070 20 20 20 20 20 20 20 20 44 65 73 63 72 69 70 74 | D +escript| 00000080 69 6f 6e 20 6f 66 20 74 68 65 20 73 65 63 6f 6e |ion of th +e secon| 00000090 64 20 61 72 67 75 6d 65 6e 74 2e 0a 0a |d argumen +t...| 0000009d
You can clearly see the embedded text formatting escape codes.
However, the same on mint 20, perl v5.30 looks thus:
perldoc junk2|hexdump -C 00000000 68 65 61 64 69 6e 67 0a 20 20 20 20 2a 61 72 67 |heading. + *arg| 00000010 75 6d 65 6e 74 31 2a 0a 20 20 20 20 20 20 20 20 |ument1*. + | 00000020 44 65 73 63 72 69 70 74 69 6f 6e 20 6f 66 20 74 |Descripti +on of t| 00000030 68 65 20 66 69 72 73 74 20 61 72 67 75 6d 65 6e |he first +argumen| 00000040 74 2e 0a 0a 20 20 20 20 2a 61 72 67 75 6d 65 6e |t... * +argumen| 00000050 74 32 2a 0a 20 20 20 20 20 20 20 20 44 65 73 63 |t2*. + Desc| 00000060 72 69 70 74 69 6f 6e 20 6f 66 20 74 68 65 20 73 |ription o +f the s| 00000070 65 63 6f 6e 64 20 61 72 67 75 6d 65 6e 74 2e 0a |econd arg +ument..| 00000080 0a |.| 00000081

No formatting escape codes
I tried the above on a completely new installation of Mint 20 with the same wrong results.
I've used Perl since +- 1999, and have generally always embedded perldoc documentation at the end of each script.
But this is the first time I have seen formatting disappear!
There is no PAGER or PERLDOC_PAGER environment variable on either computer, and terminal settings are the same (those I can change)
Any suggestions? Further info needed?

Replies are listed 'Best First'.
Re: perldoc Bold, Italic etc
by kcott (Archbishop) on Aug 29, 2021 at 19:54 UTC

    G'day miguelnixon.

    Welcome to the Monastery.

    "... forgive me if this is the wrong forum ..."

    No need to seek forgiveness. Feel free to ask any Perl-related questions here. And please don't be dissuaded by thinking you should already know something: I, with apparently more than five years of Perl under my belt than you, asked a perldoc-related question just last week.

    I suspect the differences you're seeing are OS-related, not Perl-related. There may be some configuration (or similar) setting you need to change such that "heading." becomes an equivalent with formatting code like ".[1m.[1mheading.[0m.[0m.".

    Just to mention some earlier (chronologically) points regarding environment variables:

    $ env | grep PAGE PAGER=/usr/bin/less

    I do recall using additional options with less years ago when running macOS (aka Mac OS X in earlier versions) but that appears unnecessary with the current OS.

    I don't have your OS/Perl combination available. This makes testing your specification installations impossible for me; however, general test scenarios are valid for us both. I do have Perl 5.30 on Cygwin (but nothing as early as 5.22). The following reflects my tests with 5.30 (I repeated these with 5.34 — my usual and latest, currently stable version — but saw no differences).

    I wrote pm_11136178_pod_formatting.pod:

    =encoding utf8 =head1 Emphases =over 4 =item * Plain perldoc Bold, Italic etc =item * Bold B<perldoc Bold, Italic etc> =item * Italic I<perldoc Bold, Italic etc> =item * Bold Italic B<< I<perldoc Bold, Italic etc> >> =item * Italic Bold I<< B<perldoc Bold, Italic etc> >> =item * Bold Italic Code B<<< I<< C<perldoc Bold, Italic etc> >> >>> =item * Italic Bold Code I<<< B<< C<perldoc Bold, Italic etc> >> >>> =back =cut

    Running that through perldoc I get:

    Emphases * Plain perldoc Bold, Italic etc * Bold perldoc Bold, Italic etc * Italic *perldoc Bold, Italic etc* * Bold Italic *perldoc Bold, Italic etc* * Italic Bold *perldoc Bold, Italic etc* * Bold Italic Code *"perldoc Bold, Italic etc"* * Italic Bold Code *"perldoc Bold, Italic etc"*

    I do note various asterisks and double-quotes to represent emphasis and monospace text; however, there's nothing to differentiate italicised and emboldened text. Did you see something different between 5.22 and 5.30.

    Piping the perldoc output through hexdump:

    $ perldoc pm_11136178_pod_formatting.pod | hexdump -C 00000000 45 6d 70 68 61 73 65 73 0a 20 20 20 20 2a 20 20 |Emphases. + * | 00000010 20 50 6c 61 69 6e 0a 0a 20 20 20 20 20 20 20 20 | Plain.. + | 00000020 70 65 72 6c 64 6f 63 20 42 6f 6c 64 2c 20 49 74 |perldoc B +old, It| 00000030 61 6c 69 63 20 65 74 63 0a 0a 20 20 20 20 2a 20 |alic etc. +. * | 00000040 20 20 42 6f 6c 64 0a 0a 20 20 20 20 20 20 20 20 | Bold.. + | 00000050 70 65 72 6c 64 6f 63 20 42 6f 6c 64 2c 20 49 74 |perldoc B +old, It| 00000060 61 6c 69 63 20 65 74 63 0a 0a 20 20 20 20 2a 20 |alic etc. +. * | 00000070 20 20 49 74 61 6c 69 63 0a 0a 20 20 20 20 20 20 | Italic. +. | 00000080 20 20 2a 70 65 72 6c 64 6f 63 20 42 6f 6c 64 2c | *perldo +c Bold,| 00000090 20 49 74 61 6c 69 63 20 65 74 63 2a 0a 0a 20 20 | Italic e +tc*.. | 000000a0 20 20 2a 20 20 20 42 6f 6c 64 20 49 74 61 6c 69 | * Bol +d Itali| 000000b0 63 0a 0a 20 20 20 20 20 20 20 20 2a 70 65 72 6c |c.. + *perl| 000000c0 64 6f 63 20 42 6f 6c 64 2c 20 49 74 61 6c 69 63 |doc Bold, + Italic| 000000d0 20 65 74 63 2a 0a 0a 20 20 20 20 2a 20 20 20 49 | etc*.. + * I| 000000e0 74 61 6c 69 63 20 42 6f 6c 64 0a 0a 20 20 20 20 |talic Bol +d.. | 000000f0 20 20 20 20 2a 70 65 72 6c 64 6f 63 20 42 6f 6c | *perl +doc Bol| 00000100 64 2c 20 49 74 61 6c 69 63 20 65 74 63 2a 0a 0a |d, Italic + etc*..| 00000110 20 20 20 20 2a 20 20 20 42 6f 6c 64 20 49 74 61 | * B +old Ita| 00000120 6c 69 63 20 43 6f 64 65 0a 0a 20 20 20 20 20 20 |lic Code. +. | 00000130 20 20 2a 22 70 65 72 6c 64 6f 63 20 42 6f 6c 64 | *"perld +oc Bold| 00000140 2c 20 49 74 61 6c 69 63 20 65 74 63 22 2a 0a 0a |, Italic +etc"*..| 00000150 20 20 20 20 2a 20 20 20 49 74 61 6c 69 63 20 42 | * I +talic B| 00000160 6f 6c 64 20 43 6f 64 65 0a 0a 20 20 20 20 20 20 |old Code. +. | 00000170 20 20 2a 22 70 65 72 6c 64 6f 63 20 42 6f 6c 64 | *"perld +oc Bold| 00000180 2c 20 49 74 61 6c 69 63 20 65 74 63 22 2a 0a 0a |, Italic +etc"*..|

    That looks a lot like your 5.22 ouput.

    In case you were wondering, Cygwin does support highlighting codes. I can't tell how they might differ. Here's an example:

    $ echo $PS1 \[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$

    I would investigate the OS versions differences first. Some monks may even have exactly the same combinations of OS and Perl as you; that may help more than I've been able. If you do find that it's an OS issue; please post here for the benefit of others.

    P. S. (forgot to mention): I generated HTML output via:

    pod2html --infile=pm_11136178_pod_formatting.pod --outfile=pm_11136178 +_pod_formatting.html

    When viewed in Firefox the output was exactly as expected. All formatting codes had been correctly translated to the equivalent HTML tags.

    — Ken

Re: perldoc Bold, Italic etc (updated)
by LanX (Saint) on Aug 29, 2021 at 17:25 UTC

    > There is no PAGER or PERLDOC_PAGER environment variable on either computer,

    neither PERLDOC ?

    > Any suggestions?

    perldoc has an elaborated fallback strategy, if one of the backends fails/doesn't fit. For instance it'll just emit plain text° in cmd.exe on Windows, like in your second example.

    I can't reproduce your systems, but I would read the docs for perldoc carefully and play around with the options. Especially -oman should explicitly do what you want (see perldoc#-o-output-formatname).

    Or the desired backend for the format is not in the path or ... (fill in more speculations)...???

    Like this you'll hopefully be able to narrow down the problem.

    If that's a plain shipped system Perl without changing any environment, you might need to file a bug report with Mint.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

    update

    you could play around with pager settings

    > One useful value for PERLDOC_PAGER is less -+C -E.

    and ˛ activate debugging to see how perldoc internally acts

    > Having PERLDOCDEBUG set to a positive integer will make perldoc emit even more descriptive output than the -D switch does; the higher the number, the more it emits.

    footnotes

    °) including wiki-like asterisks * surrounding *bold* text

    ˛) LAST BUT NOT LEAST! -D will list found pagers and the used backend

Re: perldoc Bold, Italic etc
by choroba (Cardinal) on Sep 01, 2021 at 08:55 UTC
    That's the new default behaviour, see this commit.

    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
Re: perldoc Bold, Italic etc
by Perlbotics (Archbishop) on Aug 29, 2021 at 18:33 UTC

    Try to

    export PERLDOC=-oterm
    or define an alias like
    builtin alias perldoc="perldoc -oterm "
    Assure, that Pod::Perldoc::ToTerm is installed and accessible. If that does not work, try -oansi instead of -oterm.

    Edit: fixed alias definition taking into account that some distros come with an alias() function.

      This is surely a valid workaround, but IMHO a system's Perl should do all this out of the box.

      So he should really try perldoc -D on both versions to see what changed and file a bug report if necessary.

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery

Re: perldoc Bold, Italic etc
by jkeenan1 (Deacon) on Aug 29, 2021 at 16:59 UTC
    Could you post the sample text in plain-text so that we can play around with it directly?
    Jim Keenan
      Many thanks to all for your replies.
      The only solution is: perldoc -oman func.pl
      It's easy enough to create an alias for this.
      Sounds almost as if perldoc 5.30 now defaults to plain text instead of pod formatting.
      Glad I now can see my documentation as intended ;-)
      Here's the plain text I was playing with:

      #!/usr/bin/perl
      print "a perl script\n";

      __END__

      =head1 B<Bold heading>

      =over 4

      =item * I<Italic item>

      Description of the first argument.

      =item * I<also Italic>

      Description of the second argument.

      =back

      =cut

      Thanks again everyone. Cheers!