避免突出顯示清單中某些單字後面的關鍵字

避免突出顯示清單中某些單字後面的關鍵字

instanceof是 Haskell 中的關鍵字。但它們也出現在錯誤訊息中,例如No instance for... arising from the use of....我想說listings的是instanceafterNo不應該被視為關鍵字(同時不完全刪除突出顯示)。是否可以?

基於禁止清單中的關鍵字, 我希望

literate={use of}{use of}6

可以解決這個問題,但事實並非如此(奇怪的是,給出 11 作為長度會No instance產生“不正確的字母常數”和“缺少數字,被視為零”)。

範例文件:

\documentclass[12pt]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1,T2A]{fontenc}
\usepackage{color}
\usepackage{listings}
\lstset{
    language=Haskell,
    basicstyle=\ttfamily\footnotesize,
    keywordstyle=\color{blue},
    literate={use of}{use of}6
}
\begin{document}
\begin{lstlisting}
<interactive>:11:1: error:
No instance for (Num Bool) arising from a use of '+'
In the expression: True + False
In an equation for 'it': it = True + False
\end{lstlisting}
\end{document}

期望的結果是NumBoolTrue仍然False突出顯示,但instanceof不應該突出顯示(最好不要更改環境內容lstlisting)。

相關內容