# listings package and misparsed strings #795

Closed
opened this Issue Aug 17, 2016 · 2 comments

Projects
None yet
3 participants
Contributor

### teepeemm commented Aug 17, 2016

 I wanted to roll up my sleeves and attempt a contribution. I thought an easy first step would be the odd formatting in the trivial examples at http://dlmf.nist.gov/LaTeXML/manual/customization/customization.latexml.html#SS3. Surely it would just be a misplaced space. I eventually figured out that it's actually a bug in listings.sty.ltxml. The \\' on the previous line gets misinterpreted and doesn't close the quote. Because the next two lines supposedly begin inside a quotation, spaces are represented incorrectly. This can be seen in the following: \documentclass{article} \usepackage{listings} \begin{document} \lstinline[language=Perl]!confused '\\' quotes;! \begin{lstlisting}[language=Perl] confused '\\' quotes; \end{lstlisting} \end{document} which results in an xml snippet of confused ’\\’␣␣quotes;’ and an output of confused ’\\’␣␣quotes;’ both times. The latter two spaces become open boxes because latexml thinks we're still inside the quote, and then needs to add a third quote at the end of the line to make sure to close it. It turns out that removing [language=Perl] from either command causes the spaces to render correctly. I think this is because without a language, there is nothing to say that strings should be formatted differently. Unfortunately, digging into listings.sty.ltxml is beyond my current capabilities. If someone else is able to, great. If we can't track down where this is coming from, then would we want to at least paper over the bug showing up in the manual by switching the last two examples? That would put the misparsed quote at the end, so that no spaces come after.

Collaborator

### dginev commented Aug 17, 2016

 Thanks for the enthusiasm to contribute back to LaTeXML @teepeemm ! Sounds like this may be an issue with either the Perl language definition for listings, or LaTeXML's interpretation of it. Possibly something for Bruce to look into if no one beats him to it.
Owner

### brucemiller commented Dec 5, 2016

 Awesome! I'd been bothered by that, but hadn't traced it back to the backslashes! Turns out I need to recognized backslashed backslashes so they don't quote the next thing in line! Thanks much for pointing to the fix (and yeah, the listings binding is pretty obscure)