Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Special formatting in pod

by ambrus (Abbot)
on Mar 25, 2007 at 19:15 UTC ( [id://606484]=CUFP: print w/replies, xml ) Need Help??

At one point, I wanted to put a line break between two lines in a pod. I couldn't figure it out how to do that at that time.

Now I know it's possible to do such things only by writing out the instructions for the special formatting (line break in this case) for all target formats you want to convert the pod to, and include a generic substitute (a paragraph break in this case) in case someone uses some other format.

In this demonstration, the linebreak will render correctly if you convert the pod to man or html, and the substitute will be used in e.g. text or latex format.

Note how you need to comment out the substitute in each formatting, because there is no way to do that in pod (there is no negated begin).

=pod =head1 ALL =begin man This sentence .br is broken .ig =end man =begin html <p> This sentence <br> is broken </p> <!-- =end html This sentence is broken. =begin html --> =end html =begin man .. =end man =cut

Replies are listed 'Best First'.
Re: Special formatting in pod
by merlyn (Sage) on Mar 25, 2007 at 20:19 UTC
    At one point, I wanted to put a line break between two lines in a pod.
    The reason there's no easy way to do that is because you have to provide the answer to the meaning of such a visual break. Paragraph breaks are provided, and they have a meaning (change of topic). What does a "line break" mean, as an abstraction, in your mind? When would it come up that I (or other pod authors) would want that meaning?
      The meaning is obvious, as layout goes: more space than a period, less than a paragraph break. Not a topic change, but a severe pause, e.g to put things the other way round, or to say "stop here and think about that". Make long paragraphs more readable, provide a hook for the eye to go back - increase redability, the like a blank line inside a block of code provides.

      --shmem

      _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                    /\_¯/(q    /
      ----------------------------  \__(m.====·.(_("always off the crowd"))."·
      ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
        The reason why I last wanted to do that, is to make a nicely formatted block of contact info.

        The only way you can do it appears to be to either put every line in a separate paragraph, or make a preformatted code block ("verbatim paragraph") out of it. Sucks.

        Ideally the text should formatted as normal text, but respecting my line breaks.

        Or maybe I should be making a bulletless list? Is that possible?

      It came up in the synopsis section when I want to show multiple commands that the user is supposed to run sequentially. The section would look like this:

      =head1 SYNOPSYS B<heapusg> [B<-n> I<interval>] I<your_program> I<args> B<drawheapg>

      The next sections would then explain that the first command generates a data file (with a default name you can override) and the second command draws a graph of it.

      Anyway, you have a point with this. The same method I show, however, can be used for other special formatting too (like nice links in html), not only line breaks.

        Howdy!

        Simply indent the lines. That indicates that these are verbatim, thus preserving line breaks. I think that even a single space is sufficient.

        yours,
        Michael
      Another problem with a single line break is that its visibility depends on the last line not being nearly full. A forced line break near the right margin doesn't stand out visually. The markup may disappear, depending on formatting you don't control.

      Anno

      The reason there's no easy way to do that is because you have to provide the answer to the meaning of such a visual break. Paragraph breaks are provided, and they have a meaning (change of topic). What does a "line break" mean, as an abstraction, in your mind? When would it come up that I (or other pod authors) would want that meaning?

      Well, even TeX provides \\ for simple line breaks: it's a feature one should use parsimoniously (I mean in simple text, special uses are a whole another matter,) but occasionally it can be useful to stress a period ending that must be stronger than a "regular" one and not just as strong as a paragraph break.

Re: Special formatting in pod
by Anonymous Monk on Oct 18, 2020 at 07:31 UTC
    You can use =item for that:
    =over =item My first piece of text is neither indented nor surrounded with newlines. It is rewrapped to fit the output page. and lines are merged. =item And here is another piece of text. It will appear right after the previous item with no extra line break between them. =back
      Nice trick. It does the job in pod2text and pod2man. But pod2html renders each line as separate paragraph and makes each line bold.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-04-19 06:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found