包含不同语言和不同关键字的列表

包含不同语言和不同关键字的列表
\lstdefinelanguage{RIPE}
{%
sensitive=t,%
    morekeywords={inetnum, netname,descr, country, admin-c, tech-c, status, mnt-by, notify, created, %
    last-modified, source, person, address, phone, e-mail, nic-hdl, notify, route, descr, origin, member-of},
}

\lstset{
   language=RIPE,
alsoletter={-},
backgroundcolor = \color{lightgray},
basicstyle=\small\ttfamily, % Global Code Style
captionpos=b, % Position of the Caption (t for top, b for bottom)
extendedchars=true, % Allows 256 instead of 128 ASCII characters
tabsize=2, % number of spaces indented when discovering a tab 
columns=fixed, % make all characters equal width
keepspaces=true, % does not ignore spaces to fit width, convert tabs to spaces
showstringspaces=false, % lets spaces in strings appear as real spaces
breaklines=true, % wrap lines if they don't fit
frame=trbl, % draw a frame at the top, right, left and bottom of the listing
frameround=tttt, % make the frame round at all four corners
framesep=4pt, % quarter circle size of the round corners
%numbers=left, % show line numbers at the left
%numberstyle=\tiny\ttfamily, % style of the line numbers
commentstyle=\color{eclipseGreen}, % style of comments
keywordstyle=\bfseries\color{red}, % style of keywords
stringstyle=\color{eclipseBlue}, % style of strings
}

\lstdefinelanguage{nmap}
{%
sensitive=t,%
    morekeywords={nmap, Host, PORT, STATE, SERVICE,VERSION, open, closed, filtered, up, down},
}

\lstset{
language={nmap},
alsoletter={-},
backgroundcolor = \color{lightgray},
basicstyle=\small\ttfamily, % Global Code Style
captionpos=b, % Position of the Caption (t for top, b for bottom)
extendedchars=true, % Allows 256 instead of 128 ASCII characters
tabsize=2, % number of spaces indented when discovering a tab 
columns=fixed, % make all characters equal width
keepspaces=true, % does not ignore spaces to fit width, convert tabs to spaces
showstringspaces=false, % lets spaces in strings appear as real spaces
breaklines=true, % wrap lines if they don't fit
frame=trbl, % draw a frame at the top, right, left and bottom of the listing
frameround=tttt, % make the frame round at all four corners
framesep=4pt, % quarter circle size of the round corners
%numbers=left, % show line numbers at the left
%numberstyle=\tiny\ttfamily, % style of the line numbers
commentstyle=\color{eclipseGreen}, % style of comments
keywordstyle=\bfseries\color{red}, % style of keywords
stringstyle=\color{eclipseBlue}, % style of strings
}

由于某种原因,它不起作用。然后我制作了一个列表,并使用 nmap 查找语言,一切正常,但如果我使用 RIPE 查找语言,则没有颜色。

我切换了两个块,但似乎只有最后定义的块被使用了。有什么解决办法吗?

答案1

是的,在环境下它起作用了,谢谢

相关内容