Perl-POD 突破列表中的关键字

Perl-POD 突破列表中的关键字

我正在尝试将 perl 脚本包含在 pod 中。似乎 listings-package 未将 pod-documentation 部分检测为注释,这会破坏列表的其余部分。如何修复此行为?

最小不工作示例(它编译并显示失败):

\documentclass[a4paper, 10pt, oneside]{scrreprt}

\usepackage[utf8]{inputenc}   % Zeichenkodierung
\usepackage[T1]{fontenc}      % Schriftart

\usepackage{xcolor,listings}                %bindet das Paket Listings ein
\definecolor{comment}{rgb}{.15,.4,.15}     % hellgruen
\definecolor{keywd1}{rgb}{.15,.15,.6}      % dunkelblau
\definecolor{keywd2}{rgb}{.35,.5,.55}      % hellblau
\definecolor{string}{rgb}{.5,.15,.15}      % dunkelrot
\definecolor{gray}{rgb}{0.4,0.4,0.4}
\definecolor{darkblue}{rgb}{0.0,0.0,0.6}
\definecolor{cyan}{rgb}{0.0,0.6,0.6}

\lstset{language=perl,
basicstyle={\small} ,
keywordstyle=\color{blue!80!black!100},
identifierstyle=,
morecomment=[s]{=pod}{=cut},           % <------------- This doesn't help!
commentstyle=\color{green!50!black!100},
stringstyle=\ttfamily,
breaklines=true,
numbers=left,
numberstyle=\tiny,
frame=single,
backgroundcolor=\color{blue!3},
caption={Java-Code},
captionpos=t,
literate= %
{Ä}{{\"A}}1
{Ö}{{\"O}}1
{Ü}{{\"U}}1
{ß}{{\ss}}1
{ä}{{\"a}}1
{ö}{{\"o}}1
{ü}{{\"u}}1
{~}{{\textasciitilde}}1
}

\begin{document}

\begin{lstlisting}[language=perl,caption={Test-Skript für Geschwindigkeit},label=script:speed]
#!/usr/bin/env perl

=pod

=head3 command-line switches

    -r, --remote <string>      The remote Host to test. This is required!
    -i, --iterations <number>  Iterations for testing.
    -v, --verbose              Print, what's currently happening.

=head3 main
Main procedure. Needed parameters: remote-host as string, iterations as number,
verbosity as empty or non-empty. Returns 0 if everything went ok, else other 
numbers.

=cut


my $bla;
doSomething(@INC, $bla);
\end{lstlisting}

\end{document}

结果:

结果显示特殊字符而不是空格

答案1

morecomment=[s]{=pod}{=cut}

是正确的做法。在这种情况下,存在编码问题,所以这=不是一个等号,而是一个类似的东西。

相关内容