# tex4ht and listings: lines don't break when using escapeinside

This is the first I'm posting a question. So, I hope I don't do anything wrong.

I've tried to get HTML from my latex document by using tex4ht. For cross-referencing within the lstlisting environment, I defined an escapeinside expression. My MWE is this. The code is written down in the file mwe.tex.

\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{listings}
\lstset{
escapeinside={(@/}{/@)}
}
\begin{document}

\begin{lstlisting}
First line (@/\label{Ref1}/@)
Second line (@/\label{Ref2}/@)
Third line (@/\label{Ref3}/@)
\end{lstlisting}

Reference to line \ref{Ref1}, \ref{Ref2}, and \ref{Ref3}.
\end{document}


When generating a PDF with pdflatex, everything is fine. In particular, there are line breaks after each line in the lstlisting environment.

First line
Second line
Third line

Reference to line 1, 2, and 3.


However, when I use htlatex mwe for getting the HTML, the line breaks are missing.

The HTML output looks like

 First line         Second line Third line

Reference to line 1, 2, and 4.



Why is the last reference pointing to line 4, whereas in the PDF, it is referred to line 3? And how can I tell tex4ht to break the lines similar to the PDF file? Any help is appreciated. Thanks in advance.

• The MWE produces the expected result on my machine (html page with correct line breaks and correct reference numbers). Do you get any warnings from htlatex/tex4ht on the command line or in the log? What is your version of pdfTex, tex4ht, lstlisting? Which web browser/OS are you using? – Marijn Oct 13 '15 at 11:15