Skip to content

Commit 44d24f5

Browse files
committed
Fix Pod::Text quoting heuristics for C<>
If the contents of C<> contained a newline right before remaining text that would not normally be quoted, the entire contents were not quoted because of an incorrectly anchored regex. Fix by anchoring at the start of the string rather than the start of the line. Thanks, van-de-bugger. Fixes #39
1 parent 890ab03 commit 44d24f5

File tree

4 files changed

+24
-7
lines changed

4 files changed

+24
-7
lines changed

Changes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
Revision history for podlators
22

3+
v6.0.3 - Not Released
4+
5+
- Fix Pod::Text quoting heuristics for C<> when the contents contains
6+
newlines. Thanks to van-de-bugger for the report. (GitHub #39)
7+
38
v6.0.2 - 2024-07-14
49

510
- Fix removal of scripts/pod2man and scripts/pod2text by make realclean,

lib/Pod/Text.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ sub cmd_c {
651651
}xms;
652652
}
653653
$text =~ m{
654-
^\s*
654+
\A\s*
655655
(?:
656656
( [\'\`\"] ) .* \1 # already quoted
657657
| \` .* \' # `quoted'
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[name]
2+
C<> with newline
3+
4+
[input]
5+
=head1 CE<lt>E<gt> WITH NEWLINE
6+
7+
What does C<--columns
8+
$COLUMNS> end up looking like?
9+
10+
[output]
11+
C<> WITH NEWLINE
12+
What does "--columns $COLUMNS" end up looking like?

t/text/snippets.t

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# Test Pod::Text behavior with various snippets.
44
#
5-
# Copyright 2002, 2004, 2006-2009, 2012, 2018-2020, 2022, 2024
5+
# Copyright 2002, 2004, 2006-2009, 2012, 2018-2020, 2022, 2024-2025
66
# Russ Allbery <[email protected]>
77
#
88
# This program is free software; you may redistribute it and/or modify it
@@ -15,7 +15,7 @@ use warnings;
1515

1616
use lib 't/lib';
1717

18-
use Test::More tests => 69;
18+
use Test::More tests => 71;
1919
use Test::Podlators qw(test_snippet);
2020

2121
# Load the module.
@@ -25,10 +25,10 @@ BEGIN {
2525

2626
# List of snippets run by this test.
2727
my @snippets = qw(
28-
alt c-with-spaces code cpp empty error-die error-none error-normal
29-
error-pod error-stderr error-stderr-opt for guesswork-quoting
30-
guesswork-no-quoting late-encoding link-rt link-url margin naive
31-
name-quotes name-quotes-none non-latin nonbreaking-space
28+
alt c-with-spaces c-with-newline code cpp empty error-die error-none
29+
error-normal error-pod error-stderr error-stderr-opt for
30+
guesswork-quoting guesswork-no-quoting late-encoding link-rt link-url
31+
margin naive name-quotes name-quotes-none non-latin nonbreaking-space
3232
nonbreaking-space-l nonbreaking-wrap nourls periods quotes-opt
3333
s-whitespace sentence-spacing utf8 verbatim
3434
);

0 commit comments

Comments
 (0)