如何在 Pod 的 L 中添加带有 URL 的链接文本?

发布于 2024-08-02 19:48:17 字数 332 浏览 9 评论 0原文

如果您要链接到其他 POD,则 L 格式化代码允许您设置链接的显示文本,如 L 中所示,但这对于 L 链接是不允许的,例如

L<http://perldoc.perl.org/strict.html>

如何为此类链接指定显示文本?或者,如何手动编写这样的链接,而无需由 pod2html 实体化的 HTML 尖括号?

The L<name> formatting code allows you to set the display text for the link if you're linking to other POD, as in L<Display Text|link_dest>, but this isn't allowed for L<scheme:...> links, such as

L<http://perldoc.perl.org/strict.html>

How do I specify a display text for such links? Alternatively, how do I manually write such a link without the angle brackets being HTML entitized by pod2html?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

锦爱 2024-08-09 19:48:17

正确的格式是这样的:

L<strict|http://perldoc.perl.org/strict.html>

另请参阅 http://justatheory.com/computers /programming/perl/sane-pod-links.html

The proper format is this:

L<strict|http://perldoc.perl.org/strict.html>

See also http://justatheory.com/computers/programming/perl/sane-pod-links.html

小巷里的女流氓 2024-08-09 19:48:17

如果你想用你的 Pod 做一些奇特的事情,那么编写一个 Pod 翻译器真的很容易。 Pod::Simple 中已经为您完成了大部分工作,因此您只需处理 L<> 的情况。 Mastering Perl 中有一个关于它的章节。

If you want to do something fancy with your Pod, it's really easy to write a Pod translator. Most of the work is already done for you in Pod::Simple, so you only need to handle the cases for L<>. There's a chapter in Mastering Perl about it.

转身以后 2024-08-09 19:48:17

http://perldoc.perl.org/perlpod.html#Formatting-Codes

L<<a href="http://www.perl.org/">http://www.perl.org/</a>>

正如您所指出的,看起来这应该可行,但也许我误解了您的问题?

编辑:
看来 pod2html 不喜欢这种方法。
找到了一个稍微复杂的解决方案

我在https://web.archive.org/web/1/http://blogs.techrepublic%2ecom%2ecom/howdoi/?p=114


#!/usr/bin/perl                                                                                                              
use strict;
use warnings;
use Pod::2::html;


my $pod_file =  $ARGV[0];
my $template =  $ARGV[1];

# Create pod2html object                                                                                                    
my $pod = Pod::2::html->new($pod_file);

# The path to the HTML template                                                                                             
$pod->template($template);

# The formatted HTML will go to STDOUT                                                                                      
$pod->readpod();

我对此进行了测试,似乎没有问题插入通用 html,这样您实际上就不需要 L<> 了。根本没有标签。
这对我来说似乎是一个不错的解决方案。

http://perldoc.perl.org/perlpod.html#Formatting-Codes

L<<a href="http://www.perl.org/">http://www.perl.org/</a>>

As you point out, it looks like this should work, but perhaps I've misunderstood your question?

EDIT:
It seems that pod2html does not like that approach.
I found a slightly more involved solution at,

https://web.archive.org/web/1/http://blogs.techrepublic%2ecom%2ecom/howdoi/?p=114


#!/usr/bin/perl                                                                                                              
use strict;
use warnings;
use Pod::2::html;


my $pod_file =  $ARGV[0];
my $template =  $ARGV[1];

# Create pod2html object                                                                                                    
my $pod = Pod::2::html->new($pod_file);

# The path to the HTML template                                                                                             
$pod->template($template);

# The formatted HTML will go to STDOUT                                                                                      
$pod->readpod();

I tested this out and it seems to have no problem interpolating generic html, so that you don't actually need th L<> tag at all.
This seems like a decent solution to me.

别忘他 2024-08-09 19:48:17

你们太接近了!您在尖括号和 URL 之间缺少必需的空格。试试这个:

I think L<< http://example.com >> is the best site on the web!

根据 perldoc perlpod ,额外的空间是强制性的(从

“一种更具可读性,也许更“简单”的方法是使用一组备用分隔符,不需要转义单个“>”。使用以标准开头的 Pod 格式化程序perl5.5.660,当且仅当开始分隔符后面有空格且结束分隔符之前有空格时,才可以使用双尖括号(“<<”和“>>”),例如,以下!就可以了:”

       C<< $a <=> $b >>

You were SO close! You're missing a required space between both angle brackets and the URL. Try this:

I think L<< http://example.com >> is the best site on the web!

The extra space is mandatory according to perldoc perlpod (scroll down from here to find it):

"A more readable, and perhaps more "plain" way is to use an alternate set of delimiters that doesn't require a single ">" to be escaped. With the Pod formatters that are standard starting with perl5.5.660, doubled angle brackets ("<<" and ">>") may be used if and only if there is whitespace right after the opening delimiter and whitespace right before the closing delimiter! For example, the following will do the trick:"

       C<< $a <=> $b >>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文