Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

listings package and misparsed strings #795

Closed
teepeemm opened this issue Aug 17, 2016 · 2 comments
Closed

listings package and misparsed strings #795

teepeemm opened this issue Aug 17, 2016 · 2 comments

Comments

@teepeemm
Copy link
Contributor

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

<text class="ltx_lst_identifier">confused</text>
<text class="ltx_lst_space">  </text>
<text class="ltx_lst_string">’\\’<text class="ltx_lst_space">␣␣</text>quotes;’</text>

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.

@dginev dginev added this to the LaTeXML-0.8.3 milestone Aug 17, 2016
@dginev
Copy link
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.

@brucemiller
Copy link
Owner

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants