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

[lilypond.lua]: non-trivial ly code doesn't compile; global options not effective #275

Open
ppenguin opened this issue Feb 4, 2024 · 1 comment

Comments

@ppenguin
Copy link

ppenguin commented Feb 4, 2024

I just discovered lilypond.lua and it might be what I was looking for.

However, I had some trouble getting it to work.

The following works well:

---
lilypond:
  relativize: yes
---

# Some songs

```lilypond { .ly-fragment ly-resolution=300 }
\new ChordNames \with {
  \override BarLine.bar-extent = #'(-1 . 3)
  \consists "Bar_engraver"
}

\chordmode {
  f1:maj7 f:7 bes:7
  c:m d:7 fis:dim
}

However, as soon as I add the lilypond block from here (examples), I get an error:

$ pandoc -i test/lp1.md --lua-filter=$(which lilypond.lua) --pdf-engine=lualatex --standalone -o test/lp1.pdf
Error running filter /nix/store/87wba0bq2w9icj63vd7m2ipl2fn1a866-pandoc-lua-filters-2021-11-05/share/pandoc/filters/lilypond.lua:
...lua-filters-2021-11-05/share/pandoc/filters/lilypond.lua:65: attempt to index a nil value (local 'fh')
stack traceback:
	...lua-filters-2021-11-05/share/pandoc/filters/lilypond.lua:49: in upvalue 'generate_image'
	...lua-filters-2021-11-05/share/pandoc/filters/lilypond.lua:83: in upvalue 'process_lilypond'
	...lua-filters-2021-11-05/share/pandoc/filters/lilypond.lua:143: in function <...lua-filters-2021-11-05/share/pandoc/filters/lilypond.lua:138>

The same happens when I add a \break to any of the above code.

As I gleaned from the lua code, this probably means that the lilypond process errored out and dind't produce an image file. But if I put the verbatim contents of the failing code block in a separate file lptst.ly and then manually run lilypond, it generates a correct looking png file:

$ lilypond -o tst.png --png test/lptst.ly
GNU LilyPond 2.24.3 (running Guile 2.2)
Processing `test/lptst.ly'
Parsing...
test/lptst.ly:1: warning: no \version statement found, please add

\version "2.24.3"

for future compatibility
Interpreting music...[8][16]
Preprocessing graphical objects...
Finding the ideal number of pages...
Fitting music on 1 page...
Drawing systems...
Converting to PNG...
Success: compilation successfully completed

The second topic:

I want to move things like ly-resolution=300 to the frontmatter (which should be possible according to the docs), but none of

---
lilypond:
  relativize: yes
  ly-resolution: 300
ly-resolution: 300
pandoc:
  ly-resolution: 300
---

had any effect.

@ppenguin
Copy link
Author

ppenguin commented Feb 4, 2024

Partial Solution

I discovered that if I omit .ly-fragment, I'm able to do \break and the orginal appoggiaturas example also works (which has in the original test markdown also .ly-fragment however, so why would it pass the test there?).

Ultimately this could mean, that it would be good to be able to tweak the ly-fragment behaviour, or provide another mechanism that allows us a kind of default preamble that will be injected for each block, so we can avoid repeated setup boilerplate.

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

1 participant