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

Handling \include correctly #7

Closed
mhohl opened this issue Aug 22, 2015 · 4 comments
Closed

Handling \include correctly #7

mhohl opened this issue Aug 22, 2015 · 4 comments

Comments

@mhohl
Copy link

mhohl commented Aug 22, 2015

Hello,

I am using lyluatex for my latest project, and I like it! One drawback (that lyluatex shares with lilypond-book so far): if I include a lilypond file in my lualatex document that has one or more
\include directives, chances in these included files do not cause lyluatex to recompile the music.

What about taking these include files into account? Something along the lines of
[snip]

local md5 = require 'md5'

function file_exists(name)
   local f=io.open(name,"r")
   if f~=nil then io.close(f) return true else return false end
end

function replaceIncludes(file)
   local content =""
   for Line in io.lines(file) do
       if Line:find("^%s*[^%%]*\\include") then
          local inclfile = Line:gsub("%s*\\include%s*\"(.*)\"", "%1")
          if file_exists(inclfile) then
             content = content .. replaceIncludes(inclfile)
          else
             content = content .. Line .. "\n"
          end
       else
          content = content .. Line .. "\n"
       end
   end
   return content
end

lyincl = replaceIncludes('test.txt')

print(md5.sumhexa(lyincl)) 

[snip]

This is not yet tested in real life situations, but
a) recursively checks for \include calls
b) ignores commented out lines
c) ignores nonexistent include files (mainly because lilypond will spot the error)

What do you think?

Best regards,

Marc

@jperon
Copy link
Owner

jperon commented Aug 23, 2015

Hello,

Thank you for your report !
Could you please send me (cataclop _ at _ hotmail dot com) a mwe showing the problem ? I must confess I don't really understand the case : as temporary files are named after file name and line width, they should be recompiled if necessary, even in included files.

@jperon
Copy link
Owner

jperon commented Sep 1, 2015

I think commit 5dcb34b should fix that. Could you test it, please ?

@mhohl
Copy link
Author

mhohl commented Sep 1, 2015

Am 01.09.2015 um 11:20 schrieb jperon:

I think commit 5dcb34b
5dcb34b
should fix that. Could you test it, please ?

A short real-life test on my current project works as expected.

Thanks a lot for the quick fix!

Cheers,

Marc


Reply to this email directly or view it on GitHub
#7 (comment).

@jperon
Copy link
Owner

jperon commented Sep 1, 2015

Thank you for reporting !

@jperon jperon closed this as completed Sep 1, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants