#StackBounty: #color #listings Color problem in listings with breaklines=true

Bounty: 50

I’m trying to highlight a specific comment type with lstsliting, and the option breaklines messes things over.

Here is the faulty output :
Faulty output

The color purple (produced by the keyword name) takes over, and colors the rest of the listing.

Here is what I need (and hat should normally produce) in terms of colors :
Desired output

Here is the MWE :

documentclass{article}
usepackage[]{geometry}
usepackage[dvipsnames,svgnames,usenames,table]{xcolor} % Smart color names
usepackage{listings}


lstdefinestyle{system}{%
%    breaklines=true,   % <-- This makes the color scheme go nuts
    breakatwhitespace=true, % <-- Even with this
    keywordstyle=color{Blue},
    basicstyle=normalfontttfamily,
    morecomment=[s][color{Blue}]{[*}{]},
    morecomment=[s][color{Green}]{[+}{]},
    morecomment=[s][color{Red}]{[-}{]},
    morecomment=[n][color{Purple}]{(name:}{)},
    morecomment=[n][color{Gray}]{(domain:}{)},
}


begin{document}


begin{lstlisting}[style=system]                  
test      X:445 Test     [+] Success1        (name:system)   (domain:web)
test      X:445 Test     [-] Failure 10.0    (name:system)   (domain:web)
test      X:445 Test     [*] Don't know 10.0 (name:system)   (domain:web)
end{lstlisting}

end{document}

Does anybody know why the breaklines options messes the colored filter ?
In the content of the listing, I can’t get rid of all the spaces, so removing them to avoid a line break is not an option.

I want to be able to have the colored filters AND the line break.


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.