jperon / lyluatex

Alternative à lilypond-book pour lualatex
MIT License
58 stars 12 forks source link

command names with dashes are split → LilyPond doesn’t recognize them #13

Closed mmeyn closed 7 years ago

mmeyn commented 7 years ago

The following code doesn’t compile. \center-column seems to be split into \center and -column before the LilyPond parser can recognize it. (\column instead of \center-column works and only the LilyPond code fed to LilyPond directly also works.)

\documentclass{article}
\usepackage{lyluatex}

\begin{document}
\begin{lilypond}
    \relative {
        \set Staff.instrumentName = \markup \center-column { "abc" "def" }
        c'
    }
\end{lilypond}
\end{document}

from the LuaLaTeX/LilyPond log:

Analysieren...
-:35:49: Fehler: syntax error, unexpected NUMBER_IDENTIFIER
\relative { \set Staff.instrumentName = \markup 
                                                \center -column { "abc" "def" } c' }
-:35:57: Fehler: not a note name: -column
\relative { \set Staff.instrumentName = \markup \center 
                                                        -column { "abc" "def" } c' }

[…]

f/tex/latex/local/lyluatex.lua:137: attempt to index local 'i' (a nil value)
stack traceback:
    /home/malte/texmf/tex/latex/local/lyluatex.lua:137: in function 'retour_tex'
    /home/malte/texmf/tex/latex/local/lyluatex.lua:51: in function 'direct_ly'
    [\directlua]:1: in main chunk.
\env@compilerly@process ...g {\localstaffsize } )}
                                                  \env@ignore 
l.10 \end{lilypond}

? 
mmeyn commented 7 years ago

However I found a workaround for this case: I build the markup in Scheme.

#(markup #:center-column ("abc" "def"))
jperon commented 7 years ago

Should be fixed in 9b415a1. All I hope is it won't introduce other bugs, but I don't think so. The problem was that lualatex separates what it sees as a command (\center) from what it sees as an argument (-column). The fix deletes the spurious space, but as a consequence, it is impossible to see wether the source had \center-column or \center -column : in either case, the fix will delete the space.

mmeyn commented 7 years ago

This fixes only \center-column, \left-column, \right-column, and \dir-column but there are a whole bunch of other commands containing dashes, e. g. \center-align, \with-color and \fret-diagram. One could do a similar “fix” for all these other commands but IMO that would be a really ugly hack.

However, if I didn’t miss something (and I went through the whole LilyPond command index, the only commands with dashes are markup and markuplist commands, so they can be input as in my workaround from August 14th (see above).

If no less ugly fix can be found I would suggest to document this limitation of lyluatex with a hint to the workaround.

jperon commented 7 years ago

Oops ! I had forgotten to change it after my tests. It will work now. I agree that the fix is quite ugly, but thinking about it, I think it's better than not using it : I don't see so many cases where anyone would use a \command followed by a space and -something, and in such rare cases, there would be workarounds.