-# Pod::ParseLink -- Parse an L<> formatting code in POD text.
-#
-# Copyright 2001, 2008 by Russ Allbery <rra@stanford.edu>
-#
-# This program is free software; you may redistribute it and/or modify it
-# under the same terms as Perl itself.
+# Parse an L<> formatting code in POD text.
#
# This module implements parsing of the text of an L<> formatting code as
# defined in perlpodspec. It should be suitable for any POD formatter. It
# exports only one function, parselink(), which returns the five-item parse
# defined in perlpodspec.
#
-# Perl core hackers, please note that this module is also separately
-# maintained outside of the Perl core as part of the podlators. Please send
-# me any patches at the address above in addition to sending them to the
-# standard Perl mailing lists.
+# SPDX-License-Identifier: GPL-1.0-or-later OR Artistic-1.0-Perl
##############################################################################
# Modules and declarations
package Pod::ParseLink;
-require 5.004;
-
+use 5.008;
use strict;
+use warnings;
+
use vars qw(@EXPORT @ISA $VERSION);
use Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(parselink);
-$VERSION = '1.09';
+$VERSION = '4.14';
##############################################################################
# Implementation
sub parselink {
my ($link) = @_;
$link =~ s/\s+/ /g;
+ my $text;
+ if ($link =~ /\|/) {
+ ($text, $link) = split (/\|/, $link, 2);
+ }
if ($link =~ /\A\w+:[^:\s]\S*\Z/) {
- return (undef, $link, $link, undef, 'url');
- } else {
- my $text;
- if ($link =~ /\|/) {
- ($text, $link) = split (/\|/, $link, 2);
+ my $inferred;
+ if (defined ($text) && length ($text) > 0) {
+ return ($text, $text, $link, undef, 'url');
+ } else {
+ return ($text, $link, $link, undef, 'url');
}
+ } else {
my ($name, $section) = _parse_section ($link);
- my $inferred = $text || _infer_text ($name, $section);
+ my $inferred;
+ if (defined ($text) && length ($text) > 0) {
+ $inferred = $text;
+ } else {
+ $inferred = _infer_text ($name, $section);
+ }
my $type = ($name && $name =~ /\(\S*\)/) ? 'man' : 'pod';
return ($text, $inferred, $name, $section, $type);
}
1;
__END__
+=for stopwords
+markup Allbery URL
+
=head1 NAME
Pod::ParseLink - Parse an LE<lt>E<gt> formatting code in POD text
-=for stopwords
-markup Allbery URL
-
=head1 SYNOPSIS
use Pod::ParseLink;
- my ($text, $inferred, $name, $section, $type) = parselink ($link);
+ my $link = get_link();
+ my ($text, $inferred, $name, $section, $type) = parselink($link);
=head1 DESCRIPTION
consider markup in sections to be significant when resolving links. See
L<perlpodspec> for more information.
-=head1 SEE ALSO
-
-L<Pod::Parser>
-
-The current version of this module is always available from its web site at
-L<http://www.eyrie.org/~eagle/software/podlators/>.
-
=head1 AUTHOR
-Russ Allbery <rra@stanford.edu>.
+Russ Allbery <rra@cpan.org>
=head1 COPYRIGHT AND LICENSE
-Copyright 2001, 2008 Russ Allbery <rra@stanford.edu>.
+Copyright 2001, 2008, 2009, 2014, 2018-2019 Russ Allbery <rra@cpan.org>
This program is free software; you may redistribute it and/or modify it
under the same terms as Perl itself.
+=head1 SEE ALSO
+
+L<Pod::Parser>
+
+The current version of this module is always available from its web site at
+L<https://www.eyrie.org/~eagle/software/podlators/>.
+
=cut
+
+# Local Variables:
+# copyright-at-end-flag: t
+# End: