Skip to content

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

@ppenguin

Description

@ppenguin

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions