Using the following
\documentclass{article}
\usepackage{filecontents}
\usepackage{listings}
\begin{filecontents*}{src.code}
<ul>
<!-- first -->
<li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li>
<!-- end -->
<li>Aliquam tincidunt mauris eu risus.</li>
<!-- second -->
<li>Vestibulum auctor dapibus neque.</li>
<!-- end -->
</ul>
\end{filecontents*}
\begin{document}
\lstinputlisting[rangeprefix=<!--\ ,%
rangesuffix=\ -->,%
language=HTML,
linerange={first-end,second-end},%
numbers=left,%
firstnumber=1,%
includerangemarker=false]{src.code}
\end{document}
I end up with the lines be numbered equally as 2 2. How can I have the lines in a given listing environment being numbered continuously starting with 1? ... whatever their "physical" split over multiple ranges might be.
linerangeseems a bit strange to me. For information on how to print certain lines of a given file, you can have a look at Using \lstinputlisting to include a file but only certain lines or line ranges – leandriis Mar 30 '18 at 09:23