Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

POD not rendering as I intend

by syphilis (Archbishop)
on Oct 14, 2007 at 10:15 UTC ( [id://644721]=perlquestion: print w/replies, xml ) Need Help??

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

Hi,

I have a typemap that looks like:
=head1 STUFF Soldier * SOLDIER INPUT SOLDIER $var = INT2PTR($type, SvIV(SvRV($arg))) OUTPUT SOLDIER $arg = newSViv(0); SV * obj = newSVrv($arg, \"Soldier\"); sv_setiv(obj, (IV)$var); SvREADONLY_on(obj); $arg; =cut
Let's call it 'crap.pod'. When I view it as 'perldoc crap' it shows up as:
STUFF Soldier * SOLDIER INPUT SOLDIER $var = INT2PTR($type, SvIV(SvRV($arg))) OUTPUT SOLDIER $arg = newSViv(0); SV * obj = newSVrv($arg, \"Soldi +er\"); sv_setiv(obj, (IV)$var); SvREADONLY_on(obj); $arg;
What do I need to do to have perldoc render the file as per the original typemap ? That is, I want 'perldoc crap' to output:
STUFF Soldier * SOLDIER INPUT SOLDIER $var = INT2PTR($type, SvIV(SvRV($arg))) OUTPUT SOLDIER $arg = newSViv(0); SV * obj = newSVrv($arg, \"Soldier\"); sv_setiv(obj, (IV)$var); SvREADONLY_on(obj); $arg;
Cheers,
Rob

Replies are listed 'Best First'.
Re: POD not rendering as I intend
by Sidhekin (Priest) on Oct 14, 2007 at 10:28 UTC

    Indent your text (even by one column), and it will be rendered verbatim.

    Anything that is not indented will be treated by paragraph, subject to various markup etc ... inluding your =head1 STUFF, so I don't think you can avoid getting that set apart. Unless you remove its =head1. ;-)

    =head1 STUFF Soldier * SOLDIER INPUT SOLDIER $var = INT2PTR($type, SvIV(SvRV($arg))) OUTPUT SOLDIER $arg = newSViv(0); SV * obj = newSVrv($arg, \"Soldier\"); sv_setiv(obj, (IV)$var); SvREADONLY_on(obj); $arg; =cut

    print "Just another Perl ${\(trickster and hacker)},"
    The Sidhekin proves Sidhe did it!

      Indent your text (even by one column), and it will be rendered verbatim

      Yes - but then if you copy the 'perldoc crap' output (without removing the leading whitespace) and save it as a typemap, you get all sorts of weird warnings when you run a 'make' process that uses that typemap:
      Warning: File './typemap' Line 3 ' INPUT' TYPEMAP entry needs 2 or 3 c +olumns Warning: File './typemap' Line 4 ' SOLDIER' TYPEMAP entry needs 2 or 3 + columns Warning: File './typemap' Line 7 ' OUTPUT' TYPEMAP entry needs 2 or 3 +columns Warning: File './typemap' Line 8 ' SOLDIER' TYPEMAP entry needs 2 or 3 + columns Warning: File './typemap' Line 12 ' SvREADONLY_on(obj);' TYPEMA +P entry needs 2 or 3 columns Warning: File './typemap' Line 13 ' $arg;' TYPEMAP entry needs +2 or 3 columns Warning: File 'typemap' Line 3 ' INPUT' TYPEMAP entry needs 2 or 3 col +umns Warning: File 'typemap' Line 4 ' SOLDIER' TYPEMAP entry needs 2 or 3 c +olumns Warning: File 'typemap' Line 7 ' OUTPUT' TYPEMAP entry needs 2 or 3 co +lumns Warning: File 'typemap' Line 8 ' SOLDIER' TYPEMAP entry needs 2 or 3 c +olumns Warning: File 'typemap' Line 12 ' SvREADONLY_on(obj);' TYPEMAP +entry needs 2 or 3 columns Warning: File 'typemap' Line 13 ' $arg;' TYPEMAP entry needs 2 +or 3 columns Warning: File 'typemap' Line 3 ' INPUT' TYPEMAP entry needs 2 or 3 col +umns Warning: File 'typemap' Line 4 ' SOLDIER' TYPEMAP entry needs 2 or 3 c +olumns Warning: File 'typemap' Line 7 ' OUTPUT' TYPEMAP entry needs 2 or 3 co +lumns Warning: File 'typemap' Line 8 ' SOLDIER' TYPEMAP entry needs 2 or 3 c +olumns Warning: File 'typemap' Line 12 ' SvREADONLY_on(obj);' TYPEMAP +entry needs 2 or 3 columns Warning: File 'typemap' Line 13 ' $arg;' TYPEMAP entry needs 2 +or 3 columns
      The idea is that 'perldoc crap' should output something that can be copy'n'pasted to a 'typemap' and run trouble-free (without having to bother about removing leading whitespace).

      Thanks Sidhekin, moritz.

      Cheers,
      Rob
      Update: Probably a silly objection. The 'perldoc' output always displays leading whitespace at the beginning of every line (afaict). That being the case, all I'm really quibbling about is the *amount* of preceding whitespace ... pointless, really :-)

        Omit your typemap from the MANIFEST, and generate it directly from crap.pod in your Makefile.PL or Build.PL script.

        open my $in, '<', 'crap.pod' or die "moan crap $!\n"; open my $tmap, '>', 'typemap' or die "typemap $!\n"; while (<$in>) { print $tmap $_ if /^=head1/ .. /=^cut/ and /^[^=]/; } close $in; close $tmap;

        Remember that xsubpp will be run much later, and won't care that typemap was created only a few seconds ago, and did not, in fact, come with the original tarball. Just make sure it renders as you want in POD, and remove any POD hackery as you write it out to the typemap file.

        Or go the other way: have a POD stub file, and merge in the contents of typemap, appropriately munged.

        • another intruder with the mooring in the heart of the Perl

Re: POD not rendering as I intend
by moritz (Cardinal) on Oct 14, 2007 at 10:18 UTC
    If you want your text to be rendered verbatim (including whitespaces), you should indent it all by the same amount of whitespace.

    See perlpod for more details.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://644721]
Approved by Sidhekin
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (2)
As of 2024-04-25 06:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found