在编写将导出为HTML的perlpod文档时,我可以在POD指令中嵌入生成的HTML文件的标题吗?
我希望能够使用该pod2html
命令将多个POD文本文件转换为HTML ,并且不希望必须--title="My Title"
在命令行上提供参数.
例如,这是一个带有perlpod格式的文本文件:
=pod
=head1 This is a heading
This is some text. I'd like to set the title of this document in the resulting HTML file.
=cut
Run Code Online (Sandbox Code Playgroud)
当我将其转换为HTML时,pod2html会发出关于没有标题的警告:
$ pod2html test.txt > test.html
/usr/bin/pod2html: no title for test.txt
Run Code Online (Sandbox Code Playgroud)
在生成的HTML文件中,标题设置为文件名(test.txt):
<?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>test.txt</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:root@localhost" />
</head>
<body style="background-color: white">
<p><a name="__index__"></a></p>
<!-- INDEX BEGIN -->
<ul>
<li><a href="#this_is_a_heading_">This is a heading.</a></li>
</ul>
<!-- INDEX END -->
<hr />
<p>
</p>
<hr />
<h1><a name="this_is_a_heading_">This is a heading.</a></h1>
<p>This is some text. I'd like to set the title of this document.</p>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我想找到一种在perpod文档中给出标题的方法,也许是这样的指令:
=title This is my custom title
Run Code Online (Sandbox Code Playgroud)
在Perl文档中,我看到文档标题设置得很好.这一切都是在pod文档本身没有文档标题的情况下完成的吗?
Pod文档中没有任何内容可以控制文档的标题.这取决于将Pod文档转换为您想要的格式的程序.用于生成文档的大多数pod2doc程序都有一个类似Pod::Text
或的模块Pod::Html
.这些都是转换过程中的大部分工作.
pod2html
拿一个--title
参数.但是,你想要的是pod2html无需你必须指定它.你可以做的是推出你自己的pod2html版本.让我们看看pod2html
脚本本身,也许你可以弄清楚你可以做些什么来获得你想要的东西.
删除所有POD文档,我看到::
use Pod::Html
pod2html @ARGV
Run Code Online (Sandbox Code Playgroud)
这就是整个计划.
看起来你可以制作一个pod2steve
程序来做你想做的事.你想要取最后一个参数(我假设你想要的是标题),然后简单地将它传递给pod2html
子程序.你pod2steve
会看起来像这样:
use strict;
use warnings;
use Pod::Html
my $program_name = $ARGV[$#ARGV];
pod2html --title=$program_name @ARGV
Run Code Online (Sandbox Code Playgroud)
这应该工作.
归档时间: |
|
查看次数: |
500 次 |
最近记录: |