How to redefine \lstinline
to automatically highlight or draw frames around all inline code snippets? E.g. using \bh
and \eh
commands from Highlight text in code listing while also keeping syntax highlighting ?
(I like the tikz solution since \f[color]box
doesn't work with some characters sequences in code, like ^^^
)
Added:
Minimal example:
\documentclass{article}
\usepackage{listings}
% (definitions from https://tex.stackexchange.com/questions/15237/highlight-text-in-code-listing-while-also-keeping-syntax-highlighting/18890#18890 should be inserted here)
% how to redefine the \lstinline command?
% Where to insert \bh and \eh commands?
\makeatletter
% \renewcommand\lstinline[1][]{%
% \leavevmode\bgroup % \hbox\bgroup --> \bgroup
% \def\lst@boxpos{b}%
% \lsthk@PreSet\lstset{flexiblecolumns,#1}% <-- \bh can be here (before '%')
% \lsthk@TextStyle \lsthk@Endgroup\@empty
% \@ifnextchar\bgroup{\afterassignment\lst@InlineG \let\@let@token}%
% \lstinline@} <-- but where to place \eh ???
\makeatother
\begin{document}
The following \emph{inline} code snippet should appear
in a frame (or highlighted) if lstinline command is properly redefined above:
\lstinline´chainl1(term, "+" ^^^ Add | "-" ^^^ Sub)´
\end{document}
I.e. how to achieve that inline code snippets in the whole document will be displayed inside small frames (or highlighted) without adding anything to \lstinline|xxx|
commands in the document but only via redefinition of the \lstinline
command itself? Is it possible?
\documentclass
so that those trying to help don't have to recreate it.