in reply to Escape newlines in POD / (Selectively) don't generate space characters instead

Is there any way to actually escape newlines such that perlpod does not generate space characters instead? I've tried playing around with the usual methods, but so far couldn't find any.
And then, there was a bit of epiphany.

One possibility that I did overlook is using Z<> to escape newlines. That's actually bending the rules, since perlpodspec states (emphasis mine):

This code is unusual in that it should have no content. That is, a processor may complain if it sees Z<potatoes>. Whether or not it complains, the potatoes text should ignored [sic].
And indeed, it does complain. At least podchecker and pod2man do. pod2html, on the other hand, does not. But even though the first two mention syntax errors, the document still seems to be parsed and rendered correctly.

Applying this to my first example:

Refer to the L<foobar section in the Module::Really::Really::Really::Very::Very::Long documentation|Z< >Module::Really::Really::Really::Very::Very::Long/foobar>.

Applying it to the second example is a bit more difficult:

This is a sentence. It's ending here, but the paragraph continues. Z< >This is another sentence.
Without the added space right before the starting part of Z<, continues. and This would be concatenated together directly.

Just to be clear: I consider this to be a crappy workaround rather than a real solution. A "real" solution would be adding whitespace escape capabilities to perlpodspec and the numerous POD parsers, which I should probably at least kick off via a bug report.

Replies are listed 'Best First'.
Re^2: Escape newlines in POD / (Selectively) don't generate space characters instead (Z<< >>)
by kcott (Archbishop) on Nov 09, 2020 at 06:07 UTC

    Instead of Z<>, you could try Z<< >>. Here's some interim results; I'll leave you to test this with the various pod* programs you've mentioned.

    Here's what I get with Z<> (probably much the same as you're seeing):

    $ cat test_pod_z.pod =pod Refer to the L<foobar section in the Module::Really::Really::Really::Very::Very::Long documentation|Z< >Module::Really::Really::Really::Very::Very::Long/foobar>. =cut $ perldoc test_pod_z.pod ... Refer to the foobar section in the Module::Really::Really::Really::Very::Very::Long documentation. POD ERRORS Hey! The above document had some coding errors, which are explaine +d below: Around line 4: A non-empty Z<>

    Now with Z<< >>. The space before >>Module... is important; without it you'll get a different error.

    $ cat test_pod_zz.pod =pod Refer to the L<foobar section in the Module::Really::Really::Really::Very::Very::Long documentation|Z<< >>Module::Really::Really::Really::Very::Very::Long/foobar>. =cut $ perldoc test_pod_zz.pod ... Refer to the foobar section in the Module::Really::Really::Really::Very::Very::Long documentation.

    Just for completeness, and because I had it handy, without the space before >>Module...:

    Refer to the foobar section in the Module::Really::Really::Really::Very::Very::Long documentation POD ERRORS Hey! The above document had some coding errors, which are explaine +d below: Around line 4: Unterminated L<Z< ... >> sequence A non-empty Z<>

    — Ken

      Instead of Z<>, you could try Z<< >>.
      Of course, a very interesting interpretation of "mandatory whitespace" when using repeated angle brackets. :)
      It does seem to let Pod::Man ignore such errors, because whitespace is ignored, but sadly doesn't seem to be a general solution either.

      Example, generated by Pod::Simple::HTML (I have slightly amended the text to include a missing "the"):

      <p>Refer to the <a>foobar section in the Module::Really::Really::Reall +y::Very::Very::Long documentation</a></p>
      While pod2html didn't throw any error, the link is clearly broken (misses a location), and, what isn't immediately seen, any data after the link is missing, too. I.e., the same HTML output is generated by this input:
      =pod Refer to the L<foobar section in the Module::Really::Really::Really::Very::Very::Long documentation|Z<< >>Module::Really::Really::Really::Very::Very::Long/foobar>. asdf fff =cut
      Losing data is bad. :/

        links/urls, they just dont wrap, quit wrapping them, wrap the text