in reply to Re^2: Escaping special characters for POD output
in thread Escaping special characters for POD output

Uploaded as String::PodQuote
  • Comment on Re^3: Escaping special characters for POD output

Replies are listed 'Best First'.
Re^4: Escaping special characters for POD output
by ikegami (Patriarch) on Dec 15, 2019 at 16:24 UTC

    Should have known I was missing things.


    The module doesn't escape «>» which is significant when generating the content of tags.

    my $s = '$a <=> $b'; my $pod = "C<" . pod_quote($s) . ">"; # Fails

    The modules doesn't escape «/» and «"» which are significant when generating the content of L<> tags.

    my $s = 'Module for This/That'; my $pod = "L<" . pod_quote($s) . "|Some::Module>"; # Fails

    Creating a hash with the replacements should be faster than what you're using now.

    Note that «<» only requires escaping when preceded by an ASCII capital letter.

      Thanks a lot! Didn't realize one might use pod_quote() to insert text inside a POD link. I've incorporated all your suggestions and uploaded version 0.002.

        ow, the leading look-behind will slow things down a lot.

        my %transforms = ( ( map { "$_<" => "$_E<lt>" } 'A'..'Z' ), ">" => "E<gt>", " " => "E<32>", "\t" => "E<9>", "=" => "E<61>", "/" => "E<sol>", "|" => "E<verbar>", ); s{ ( [A-Z]< | [>/|] | ^[ \t=] ) }{$transforms{$1}}g;