
Simplificando, gostaria que meus delimitadores de intervalo fossem brancos para que não aparecessem se eu mostrar um bloco de código. Eu também gostaria de omitir completamente alguns comentários de bloqueio. Eu li o listings
manual e não consigo entender por que isso não está funcionando.
Eu uso a morecomment=[s][\color{white}]{\#~}{~\#}
opção, com os marcadores iguais aos do prefixo/sufixo do intervalo. Também quero usar a morecomment=[is]{"""~}{~"""}
opção de omitir comentários de bloco (Python) com o til antes e depois. Eu tentei colocar uma barra preta antes do til também.
Alguma ideia? Eu sinto que isso deve ser uma solução fácil.
Código LaTeX
\documentclass[11pt,a4paper]{article}
\usepackage{xcolor}
\usepackage{textcomp}
\usepackage{listings} %
\lstset{
language=Python,
basicstyle=\ttfamily\small\color{blue},% just to show that colors are working
breaklines=true,
tabsize=4,
escapeinside={\#`}{`},
includerangemarker=false,
rangeprefix={\#~},
rangesuffix={~\#},
% moredelim=[s][\color{white}]{\#~}{~\#},% I want to make the range delimters white, this is not working
morecomment=[s][\color{white}]{\#~}{~\#},% I tried usign more delim, and more comment to no avail
morecomment=[is]{"""~}{~"""}, % I want to omit block comments (invisible), this is not working
}
\begin{document}
\section{Some Sample code boxes}
\subsection{Excerpt of Code}
\lstinputlisting[
language=Python,
linerange=beg:def-end:def,
]{Ex.py}
\subsection{Full Code, delimiters hidden}
\lstinputlisting[%
caption={Some Python code},%
language=Python%
]{Ex.py}
\end{document}
Ex.py Código Python
"""
Some block comment
"""
"""~
Some block comment I want omitted entirely
~"""
# I want the range delimiters below whited out so they do not appear on the full code block
#~beg:def~#
def y(x, a=1, b=1, c=1):
return a*x**2 + b*x + c #`\label{lin1}`
#~end:def~#
Some_other_code = 1