[tex4ht] Spurious line break (<br />) with \lstinputlisting
Denis Bitouzé
dbitouze at wanadoo.fr
Sun Sep 9 11:25:01 CEST 2012
Hello,
let us compile, with htlatex, the following test1.tex and test2.tex
files (that should lead to the same html output):
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% test1.tex %
%%%%%%%%%%%%%
\documentclass{article}
\usepackage{listings}
\begin{document}
\begin{lstlisting}
test
\end{lstlisting}
\end{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% test2.tex %
%%%%%%%%%%%%%
\documentclass{article}
\usepackage{filecontents}
\begin{filecontents*}{test.pgm}
test
\end{filecontents*}
\usepackage{listings}
\begin{document}
\lstinputlisting{test.pgm}
\end{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
The interesting parts of test1.html and test2.html (reformatted by
myself) are:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% interesting part of test1.html %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
<div class="lstlisting" id="listing-1">
<span class="label">
<a id="x1-2r1"></a>
</span>
test
</div>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% interesting part of test2.html %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
<div class="lstinputlisting">
<a id="x1-2"></a>
<span class="cmtt-10">
 
</span>
<br />
<span class="label">
<a id="x1-3r1"></a>
</span>
<span class="cmtt-10">
test
</span>
</div>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
In test2.html, we first notice a spurious non-break space, probably not
so disturbing. What is much more inconvenient is the spurious line break
(<br />) that make every lstinputed listing starting by a blank line.
The following test.tex file, to be compiled with:
htlatex test "test"
highlights the trouble:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% test.tex %
%%%%%%%%%%%%
\documentclass{article}
\usepackage{filecontents}
\begin{filecontents*}{test.pgm}
test
\end{filecontents*}
\begin{filecontents*}{test.cfg}
\Preamble{html}
\Css{div.lstinputlisting {border: 1px solid;}}
\begin{document}
\EndPreamble
\end{filecontents*}
\usepackage{listings}
\lstset{numbers=left}
\begin{document}
\lstinputlisting{test.pgm}
\end{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
I had a look at listings.4ht but I'm not not sure what to change in it
without side effects.
Any help would be strongly welcome :)
--
Denis
More information about the tex4ht
mailing list