I would like to highlight code in a listlisting environment. I tried two techniques: using \usepackage{lstlinebgrd} and using \usepackage{color} (based on this conversation) but none really match what I want. If a line of code is too long to fit on one line, - colorbox will not respect the line break - lstlinebgrd will respect the line break but won't highlight the second line (see example)
In top of that, colorbox creates white spaces in the frame of the lstlisting.
Would you know a solution that would work even with long lines in lstlisting?
MWE (it's a bit long as I want to show all the lstlisting options I use on my main doc):
\documentclass{article}
\usepackage{color}
\usepackage[dvipsnames]{xcolor}
\usepackage{listings}
\usepackage{lstlinebgrd}
\usepackage{listings}
\usepackage{lstlinebgrd}
\lstset{columns=fullflexible,
basicstyle=\small,
breakatwhitespace=false,
breaklines=true,
captionpos=b,
commentstyle=\color{ForestGreen},
frame=single,
extendedchars=true,
keywordstyle=\color{blue},
language=Python,
numbers=left,
numbersep=5pt,
numberstyle=\scriptsize\color{gray},
rulecolor=\color{black},
showspaces=false,
showstringspaces=false,
showtabs=false,
stepnumber=1,
stringstyle=\color{purple},
tabsize=2,
title=\lstname,
belowskip=-1em,
aboveskip=1em,
belowcaptionskip=0em,
}
\begin{document}
First example
\begin{lstlisting}[escapechar=!]
dummycode
!\colorbox{blue!35}{dummycode-dummycode-dummycode-dummycode-dummycode-dummycode-dummycode-dummycode-}!
\end{lstlisting}
second example
\begin{lstlisting}[
linebackgroundcolor={%
\ifnum\value{lstnumber}=2
\color{green!35}
\fi
}
]
dummycode
dummycode-dummycode-dummycode-dummycode-dummycode-dummycode-dummycode-dummycode
\end{lstlisting}
\end{document}