I'm trying to using the listings
package to generate nice listings of some Lisp-style code (where line comments begin with a ;
). I'd like to keep the code compilable, and so put the range markers inside of a comment. However, characters go missing (or not enough are removed, depending on your perspective) once comment syntax is enabled, and when the texcl
option is enabled with comments, listings
doesn't seem to find the end of range marker at all! Here's an example of the problem, and the code that creates it:
\documentclass{article}
\usepackage{listings}
\begin{document}
\lstset{%
basicstyle=\ttfamily\small,%
rangeprefix=MARK\ ,%
includerangemarker=false,%
}
$-$texcl, $-$comment
\begin{lstlisting}[linerange=startx-endx]
;; Some commentary before the marker
;;MARK startx
a line to include
;; a comment line to include $x^2$
;;MARK endx
;; Stuff after the range marker
\end{lstlisting}
$+$texcl, $-$comment
\lstset{texcl=true}
\begin{lstlisting}[linerange=startx-endx]
;; Some commentary before the marker
;;MARK startx
a line to include
;; a comment line to include $x^2$
;;MARK endx
;; Stuff after the range marker
\end{lstlisting}
$-$texcl, $+$comment
\lstset{texcl=false,comment=[l];}
\begin{lstlisting}[linerange=startx-endx]
;; Some commentary before the marker
;;MARK startx
a line to include
;; a comment line to include $x^2$
;;MARK endx
;; Stuff after the range marker
\end{lstlisting}
$+$texcl, $+$comment
\lstset{texcl=true,comment=[l];}
\begin{lstlisting}[linerange=startx-endx]
;; Some commentary before the marker
;;MARK startx
a line to include
;; a comment line to include $x^2$
;;MARK endx
;; Stuff after the range marker
\end{lstlisting}
\end{document}