How to highlight (color/draw attention to) a particular snippet in Minted

The minted documentation has an example using escapeinside. I’m just copying it here:

\begin{minted}[escapeinside=||]{py}
def f(x):
    y = x|\colorbox{green}{**}|2
    return y
\end{minted}

Highlights as

screenshot


You can highlight certain lines with highlightlines={1,2-3,5-10}, e.g.

Screenshot of rendered code showing highlighted lines

\begin{minted}[highlightlines={1,3-4,6-10}]{python}
def f(x):
    y = x ** 2
    return y

def f(x):
    y = x ** 2
    return y

def f(x):
    y = x ** 2
    return y
\end{minted}

You can change the color by using, say, highlightcolor=red. In general, quoting from the minted package documentation:

highlightcolor: Set the color used for highlightlines, using a predefined color name from color or xcolor, or a color defined via \definecolor