PodSpelling(通过Perlcritic运行)抱怨“ html”,即使我已将其添加到stopwords
:
=for stopwords html
=head2 some function
Generates an index.html page.
=cut
得到:
robert@saaz:~$ perlcritic --brutal test.pl | grep html
Check the spelling in your POD: html at line 1, column 1. See page 148 of PBP. (Severity: 1)
(grep
在这个最小的示例中,我通过管道输出忽略了与拼写无关的其他抱怨。)
如果我将POD更改为使用C<index.html>
或F<index.html>
,或者将其重写为a .html file
,或者添加“ index.html”作为停用词,则拼写检查器很高兴。第一个对我来说有意义(不要检查代码段或文件名),但是我看不出“ index.html”和“ .html”之间的最大区别是什么。
它可以工作,=for stopwords index.html
因为当它紧挨空格时会忽略该点吗?不过,我只是在猜测。
为什么我stopword html
不适合“ index.html”,如果我不想使用C<...>
或,该如何解决F<...>
呢?
Pod :: Wordlist的作者以这种方式实现了它。他们希望确保将诸如“ eg ”之类的缩写作为一个整体传递给拼写检查器。由于停用词的拆分和剥离是在将单词表传递给拼写检查器之前完成的,因此你不能同时拥有两者。另一方面,默认拼写检查器为aspell
。在我看来,无论缩写是否按期分割,缩写都可以通过检查。
因此,你可以像这样更改Pod / Wordlist.pm:
#line 129
sub _strip_a_word {
my ($self, $word) = @_;
my $remainder;
# try word as-is, including possible hyphenation vs stoplist
if ($self->is_stopword($word) ) {
$remainder = '';
}
# check individual parts of hyphenated or period separated word,
# keep whatever isn't a stopword as individual words
# aspell will accept split words for abbreviations as well
# 'e.g' passes like 'e g' does
elsif ( $word =~ /-|\./ ) {
my @keep;
for my $part ( split /-|\./, $word ) {
push @keep, $part if ! $self->is_stopword( $part );
}
$remainder = join(" ", @keep) if @keep;
}
# otherwise, we just keep it
else {
$remainder = $word;
}
return $remainder;
}