1Pod::ParseLink(3) User Contributed Perl Documentation Pod::ParseLink(3)
2
3
4
6 Pod::ParseLink - Parse an L<> formatting code in POD text
7
9 use Pod::ParseLink;
10 my $link = get_link();
11 my ($text, $inferred, $name, $section, $type) = parselink($link);
12
14 This module only provides a single function, parselink(), which takes
15 the text of an L<> formatting code and parses it. It returns the
16 anchor text for the link (if any was given), the anchor text possibly
17 inferred from the name and section, the name or URL, the section if
18 any, and the type of link. The type will be one of "url", "pod", or
19 "man", indicating a URL, a link to a POD page, or a link to a Unix
20 manual page.
21
22 Parsing is implemented per perlpodspec. For backward compatibility,
23 links where there is no section and name contains spaces, or links
24 where the entirety of the link (except for the anchor text if given) is
25 enclosed in double-quotes are interpreted as links to a section
26 (L</section>).
27
28 The inferred anchor text is implemented per perlpodspec:
29
30 L<name> => L<name|name>
31 L</section> => L<"section"|/section>
32 L<name/section> => L<"section" in name|name/section>
33
34 The name may contain embedded E<> and Z<> formatting codes, and the
35 section, anchor text, and inferred anchor text may contain any
36 formatting codes. Any double quotes around the section are removed as
37 part of the parsing, as is any leading or trailing whitespace.
38
39 If the text of the L<> escape is entirely enclosed in double quotes,
40 it's interpreted as a link to a section for backward compatibility.
41
42 No attempt is made to resolve formatting codes. This must be done
43 after calling parselink() (since E<> formatting codes can be used to
44 escape characters that would otherwise be significant to the parser and
45 resolving them before parsing would result in an incorrect parse of a
46 formatting code like:
47
48 L<verticalE<verbar>barE<sol>slash>
49
50 which should be interpreted as a link to the "vertical|bar/slash" POD
51 page and not as a link to the "slash" section of the "bar" POD page
52 with an anchor text of "vertical". Note that not only the anchor text
53 will need to have formatting codes expanded, but so will the target of
54 the link (to deal with E<> and Z<> formatting codes), and special
55 handling of the section may be necessary depending on whether the
56 translator wants to consider markup in sections to be significant when
57 resolving links. See perlpodspec for more information.
58
60 Russ Allbery <rra@cpan.org>.
61
63 Copyright 2001, 2008, 2009, 2014, 2018 Russ Allbery <rra@cpan.org>
64
65 This program is free software; you may redistribute it and/or modify it
66 under the same terms as Perl itself.
67
69 Pod::Parser
70
71 The current version of this module is always available from its web
72 site at <https://www.eyrie.org/~eagle/software/podlators/>.
73
74
75
76perl v5.26.3 2018-05-07 Pod::ParseLink(3)