【问题标题】:perldoc does not display text between sectionperldoc 不显示节之间的文本
【发布时间】:2022-11-27 14:53:08
【问题描述】:

我有这个 POD 文件:

=head1 Create professional slideshows with Mojolicious::Plugin::RevealJS


=head2 Install and run a Mojolicious server

Santa's elf had a problem. He had to write very fast a presentation and show it to a bunch of new elf's.
The email assigning this to him was sent by Santa himself.
The elf started to look on Metacpan and found this module: L<Mojolicious::Plugin::RevealJS|https://metacpan.org/pod/Mojolicious::Plugin::RevealJS>

He quickly typed the following commands:

C<cpanm Mojolicius Mojolicious::Plugin::RevealJS>

Now he could generate an mojo lite app using:

C<mojo generate lite-app slide_show>

Because the elf was trained in the ancient arts  of the elders
he cloud open new file with vim and paste this code in:

=begin perl

use Mojolicious::Lite -signatures;

app->static->paths(['.']);

plugin 'RevealJS';

any '/' => { template => 'presentation', layout => 'revealjs' };

app->start;

=end perl

当我运行perldoc t.pod 时,'=begin perl' 和'=end perl' 之间的代码不可见。我不明白我做错了什么。

【问题讨论】:

  • 您可能只想将代码位缩进一次(例如,几个空格或一个制表符)。
  • 此外,这看起来应该是一个 Perl Advent 日历条目。我们还缺少一些。 cfp.perladvent.org

标签: perl perl-pod


【解决方案1】:

perlpod documentation 说...

For、begin 和 end 将使您拥有文本/代码/数据区域,这些区域通常不会被解释为正常的 Pod 文本,而是直接传递给特定的格式化程序,或者在其他方面是特殊的。可以使用该格式的格式化程序将使用该区域,否则它将被完全忽略。

这格式化程序在这种情况下,perldoc 用来将您的 POD 呈现为文本。我怀疑它不知道如何处理 perl 格式,所以它忽略了它。

生成 HTML 的格式化程序可能知道如何处理 perl 格式,并可能将其替换为具有语法高亮显示的代码块。

如果您希望 POD 中的代码示例始终显示为代码,请改用 verbatim paragraph。这是通过在前面添加缩进来完成的。


=head2 frobnicate($foo)

This function frobnicates the C<$foo>.

    my $bar = frobnicate($foo)

=cut

sub frobnicate { ... }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-05-02
    • 1970-01-01
    • 2020-10-18
    • 1970-01-01
    • 1970-01-01
    • 2020-04-27
    • 2015-06-10
    相关资源
    最近更新 更多