2009-08-22 19 views
7

L<name>格式代码,您可以设置,如果你链接到其他POD,如L<Display Text|link_dest>链接显示文本,但这是不允许的L<scheme:...>链接,如如何将文本链接到Pod的L <>中的URL?

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

怎么办我为这些链接指定显示文本?或者,我如何手动编写这样的链接,而不使用HTML标记为pod2html的HTML标记?

回答

1

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,这样你实际上并不需要个大号< >标签。 这对我来说似乎是一个体面的解决方案。

+1

我试过这个结构 - L <foo>,但运行pod2html时出现以下错误:/ opt/local/bin/pod2html:debugging.pod:无法解析L << a href =“http://perldoc.perl .org/strict.html“>第6段。 我在做一些明显错误的事情吗? – 2009-08-23 08:38:52

1

如果你想对你的Pod做些事情,编写Pod翻译器非常简单。大部分工作已经在Pod :: Simple中完成,因此您只需要处理L<>的情况。关于它的Mastering Perl有一章。

1

你就这么接近!您缺少尖括号和网址之间的必填空格。试试这个:

"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 >> 
+0

几乎那里 - 使用该风格在pod2text(perldoc)中工作,但pod2html扼流圈。我使用的格式是L <<严格doc | http://perldoc.perl.org/strict.html >>。 – 2010-10-02 16:50:50

相关问题