[Tex/LaTex] \prevdepth error with mdframed and listings

listingsmdframed

I get strange errors with the last versions of mdframed (v 1.4) and listings (v 1.4). Here is a minimal example:

\documentclass{minimal}
\usepackage{mdframed}
\usepackage{listings}

\begin{document}
\begin{mdframed}
\begin{lstlisting}
blah
\end{lstlisting}
bloh
\end{mdframed}
\end{document}

The error I get is

You can't use \prevdepth in horizontal mode.

which I don't really understand… Any pointer as to what is going on would be greatly appreciated.

Best Answer

As @egreg wrote in the comment it seems that listings changed the internal definition of \par without reseting. However based on great comments of @DavidCarliste and @egreg in the chat I fixed the problem.

Please try the new version on github.

With the new version I get 0 errors and the following result:

enter image description here

Related Question