jperon / lyluatex

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

single % comment in included lilypond file breaks compilation #197

Closed fedelibre closed 6 years ago

fedelibre commented 6 years ago

If a included file contains a comment, lyluatex stops with this error:

(/home/fede/.local/texlive/2017/texmf-dist/tex/latex/graphics/lscape.sty))(load
 luc: /home/fede/.local/texlive/2017/texmf-var/luatex-cache/generic/fonts/otl/l
msans10-regular.luc)(load luc: /home/fede/.local/texlive/2017/texmf-var/luatex-
cache/generic/fonts/otl/lmmono10-regular.luc)...al/texlive/2017/texmf-dist/scri
pts/lyluatex/lyluatex.lua:841: invalid use of '%' in replacement string
stack traceback:
    [C]: in function 'gsub'
    ...al/texlive/2017/texmf-dist/scripts/lyluatex/lyluatex.lua:841: in function '
flatten_content'
    ...al/texlive/2017/texmf-dist/scripts/lyluatex/lyluatex.lua:1082: in function 
'output_filename'
    ...al/texlive/2017/texmf-dist/scripts/lyluatex/lyluatex.lua:531: in function '
calc_properties'
    ...al/texlive/2017/texmf-dist/scripts/lyluatex/lyluatex.lua:1088: in function 
'process'
    [\directlua]:1: in main chunk.
\ly@compilescore ...directlua {ly.score:process()}

l.22 \end{lilypond}

? 

Here's the included file. Note that if I use a double comment (%%) there's no error:

$ cat nostringnumber.ly 
\layout {
  % Use two comment signs to avoid lyluatex error
  \context {
    \Staff
    \omit StringNumber
  }
}

and the tex file. Note that the comment within the lilypond environment causes no error:

$ cat rel.tex 
\documentclass{book}
\usepackage{lyluatex}

\begin{document}

Trying to include a LilyPond file containing a custom layout:

\begin{lilypond}[nofragment]
\include "nostringnumber.ly"
% This is a comment.
music = \relative {
  \time 2/4
  c'4\3 e\2 |
  a,2\4 \bar "|." |
}
\score {
  \new PianoStaff <<
    \new Staff { \clef "treble_8" \music }
    \new TabStaff { \clef "moderntab" \new TabVoice \music }
  >>
}
\end{lilypond}

\end{document}
uliska commented 6 years ago

@fedelibre please confirm that this works. @jperon please confirm that I didn't miss anything with simply replacing % with # in flatten_content().

fedelibre commented 6 years ago

I confirm it works. Thanks

jperon commented 6 years ago

OK for me. Sorry for my long silence, I'm too busy right now to work on lyluatex, and will be till june. @uliska Many thanks !

andrewacashner commented 6 years ago

I encountered the same problem, but with %% as well: an input file containing comments results in invalid use of '%' in replacement string. Using TeXLive 2018 with most recent updates. The input file has several lines that begin with %% text... and no other comments.

andrewacashner commented 6 years ago

Actually the same thing happens even when there are no comment characters at all in the input file!

uliska commented 6 years ago

@andrewacashner if you are using lyluatex from the TeXLive installation you will not have these latest fixes. These are only available from the Git repository until the next release.

andrewacashner commented 6 years ago

@uliska Thanks - I realized this is actually a problem with the includepaths option, but the current version from GitHub does not have the same bug.