2009-08-22 56 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