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

CSName parameters should (sometimes?) expand protected macros #1006

Closed
dginev opened this issue Jun 10, 2018 · 4 comments
Labels
Milestone

Comments

@dginev
Copy link
Collaborator

@dginev dginev commented Jun 10, 2018

Minimal latex example:

\documentclass{article}
\usepackage{etoolbox}
\begin{document}

\expandafter\def\csname test-def\endcsname{prints the word def}
\expandafter\def\csname test-robust\endcsname{prints the word robust}

\def\mydef{def}
\newrobustcmd\myrobust{robust}

\csname test-\mydef\expandafter\endcsname

\csname test-\myrobust\expandafter\endcsname

\end{document}

The PDF result is:

prints the word def
prints the word robust

The latexml result is correct for the def case, but fails with an error in the robust case:

Error:unexpected:\myrobust The control sequence \myrobust should not appear between \csname and \endcsname

Tracing this down, I landed in State::lookupExpandable where this peculiar line is responsible for the discrepancy:

    && ($toplevel || !$$defn{isProtected})) { # is this the right logic here? don't expand unless digesting?

Simply commenting out that condition gets the example working, and fixes the general issue of using robust macros in expandable contexts.

However, running a make test shows failures in various places, so I'm assuming the real adjustment is more subtle.

@dginev dginev added this to the LaTeXML-0.8.4 milestone Jun 10, 2018
@dginev dginev changed the title readXToken should expand protected macros readXToken should (sometimes?) expand protected macros Jun 10, 2018
@dginev

This comment has been minimized.

Copy link
Collaborator Author

@dginev dginev commented Jun 10, 2018

Alternatively, maybe the CSName parameter type should expand with the $toplevel flag set to true? Would need to read into the documentation to really know what's ajar.

@dginev dginev modified the milestones: LaTeXML-0.8.4, LaTeXML-0.8.3 Jun 10, 2018
@dginev

This comment has been minimized.

Copy link
Collaborator Author

@dginev dginev commented Jun 10, 2018

FWIW, switching the toplevel flag to true and ensuring it's passed to the State method keeps all tests passing. I will add my commits to the etoolbox PR, but feel free to offer feedback in this issue - trying to avoid clutter.

Side-note, I had mentioned the \protected mechanism print in \meaning via email to Bruce and I'll also add my tweak to that to the PR.

@dginev

This comment has been minimized.

@dginev dginev changed the title readXToken should (sometimes?) expand protected macros CSName parameters should (sometimes?) expand protected macros Jun 10, 2018
@dginev

This comment has been minimized.

Copy link
Collaborator Author

@dginev dginev commented Jul 11, 2018

Solved by merging #978

@dginev dginev closed this Jul 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.