我怎样才能摆脱 Perl 的 Pod 的空行,这样它们就不会出现在 Pod::Usage 中?

发布于 2024-09-27 04:06:35 字数 467 浏览 7 评论 0原文

我有以下与 getopt::long: 一起使用的 pod

=head1 SYNOPSIS

foo [OPTION]... [URL]...

=head1 OPTIONS

=over 20

=item B<-h, --help>

Print a brief help message and exits.

=item B<-i, --input=FILE>

Reads from FILE

=back

=cut

,当我提供 -h 时它会产生:

Usage:
    foo [OPTION]... [URL]...

Options:
    -h, --help          Print a brief help message and exits.

    -i, --input=FILE    Reads from FILE

我的问题是:如何删除 -h 和 -i 之间的空行?

I have following pod which I used with getopt::long:

=head1 SYNOPSIS

foo [OPTION]... [URL]...

=head1 OPTIONS

=over 20

=item B<-h, --help>

Print a brief help message and exits.

=item B<-i, --input=FILE>

Reads from FILE

=back

=cut

and when I provides -h it produces:

Usage:
    foo [OPTION]... [URL]...

Options:
    -h, --help          Print a brief help message and exits.

    -i, --input=FILE    Reads from FILE

My question is: how can I remove empty line between -h and -i ?

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

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

发布评论

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

评论(1

野鹿林 2024-10-04 04:06:35

Pod::Usage 仅调用 Pod 格式化程序(例如 perldocText::Pod)来从 Pod 生成使用消息。您编写的 Pod 代码将被这些工具格式化为几行空行。如果您不需要这些,请编写不同的 Pod。例如,

=over 4

=item B<-h>                     Print a brief help message and exits.

=item B<-i>, B<--input=FILE>    Reads from FILE

=back

不幸的是,当转换为其他格式(例如 HTML)时,它看起来不太好,并且您将失去选项及其描述的良好垂直对齐。然而,由于 Pod::Usage 实际上是用于命令行程序的,因此优化终端上文本的可读性似乎是合理的,而不是让 HTML 或类似内容看起来不错。

Pod::Usage just calls a Pod formatter like perldoc or Text::Pod to generate the usage messages from your Pod. The Pod code you've written will be formatted with a couple of empty lines by those tools. If you don't want those, write different Pod. For example

=over 4

=item B<-h>                     Print a brief help message and exits.

=item B<-i>, B<--input=FILE>    Reads from FILE

=back

Unfortunately that won't look as nice when being converted into other formats such as HTML, and you're losing the nice vertical alignment of options and their descriptions. However, as Pod::Usage is really intended for command-line programs, it seems to be reasonable to optimise for readability of text on a terminal instead of having things look good in HTML or similar.

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