LY(1)

πŸ“¦
version 0.9.9 Β· 5 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

🌸 NAME 🌸

okay so bestie, meet LY(1) from python-ly β€” the manual page for ly, a tool for manipulating LilyPond source files. The manual name is LY(1), and the source is python-ly. Iconic. πŸ’…

Usage:

ly [options] commands file, ...

✨ OPTIONS ✨

  • -v, --version β€” show the version number and exit.
  • -h, --help β€” show this help text and exit.
  • -i, --in-place β€” overwrite input files. yes, literally overwrite them, bestie.
  • -o,--output NAME β€” output file name.
  • -e,--encoding ENC β€” (input) encoding, default UTF-8.
  • --output-encoding ENC β€” output encoding, defaulting to the input encoding.
  • -l,--language NAME β€” default pitch name language, defaulting to nederlands.
  • -d <variable=value> β€” set a variable.
the special option -- considers the remaining arguments to be file names. periodt.

πŸ¦‹ ARGUMENTS πŸ¦‹

the command is one argument with semicolon-separated commands. in most cases you’ll quote the command so that it’s seen as one argument. quote it, bestie, let it be one argument. 🫢

you can specify more than one LilyPond file. if you want to process many files and write the results of the operations on each file to a separate output file, you can use two special characters in the output filename:

  • a * gets replaced with the full path name of the current input file, without extension.
  • a ? gets replaced with the input filename, without path and extension.

if you don’t want * or ? replaced in the output filename, you can set -d replace-pattern=false. no cap.

if you don’t specify input or output filenames, standard input is read and standard output is written to. very demure, very stream-friendly. ✨


πŸŽ€ COMMANDS πŸŽ€

informative commands that write information to standard output and do not change the file

  • mode β€” print the mode of the document, guessing if not given.
  • version β€” print the LilyPond version, if it’s set in the document.
  • language β€” print the pitch name language, if it’s set in the document.

commands that change the file

  • indent β€” re-indent the file.
  • reformat β€” reformat the file.
  • translate <language> β€” translate the pitch names to the language.
  • transpose <from> <to> β€” transpose the file like LilyPond would do; pitches are given in the nederlands language.
  • abs2rel β€” convert absolute music to relative.
  • rel2abs β€” convert relative music to absolute.
  • simplify-accidentals β€” replace notes with accidentals as much as possible with their natural neighbors.
  • write [filename] β€” write the file to the given filename or the output variable. if the last command was an editing command, write is automatically called.

commands that export the file to another format

  • musicxml [filename] β€” export to MusicXML. it’s in development and far from complete, bestie, so manage expectations.
  • highlight [filename] β€” export the document as syntax colored HTML.
  • hl [filename] β€” alias for highlight.

between commands, you can set or unset a variable using

  • variable=value β€” set a variable to value. special values are true and false, which are interpreted as boolean values, or digits, which will be interpreted as integer values.
  • variable= β€” unset a variable.

🌈 VARIABLES 🌈

the following variables can be set to influence the behaviour of commands. if there’s a default value, it’s written between brackets. slay. πŸ’–

  • mode β€” mode of the file to read, default automatic. can be one of: lilypond, scheme, latex, html, docbook, texinfo.
  • output [-] β€” the output filename, also set by -o argument.
  • encoding [UTF-8] β€” encoding to read, also set by -e argument.
  • default-language [nederlands] β€” the pitch names language to use by default, when not specified otherwise in the document.
  • output-encoding β€” encoding to write; defaults to encoding, also set by the --output-encoding argument.
  • in-place [false] β€” whether to overwrite input files; same as -i.
  • backup-suffix [~] β€” suffix to use when editing files in-place. if set, backs up the original file before overwriting it.
  • replace-pattern [true] β€” whether to replace * and ? in the output filename.
  • rel-startpitch [true] β€” whether to write relative music with a startpitch.
  • rel-absolute β€” whether to assume that the first pitch in a relative expression without specified startpitch is absolute. if false, it is assumed to be relative to c'. if true, it is assumed to be absolute, in fact relative to f. if not set, this variable defaults to true only when the LilyPond version in the document >= 2.18.
  • indent-tabs [false] β€” whether to use tabs for indent.
  • indent-width [2] β€” how many spaces for each indent level, if not using tabs.
  • full-html [True] β€” if set to True, a full document with syntax-highlighted HTML will be exported; otherwise only the bare content wrapped in an element configured by the wrapper- variables.
  • stylesheet β€” filename to reference as an external stylesheet for syntax-highlighted HTML. this filename is literally used in the <link rel="stylesheet"> tag.
  • inline-style [false] β€” whether to use inline style attributes for syntax-highlighted HTML. by default a css stylesheet is embedded.
  • number-lines [false] β€” whether to add line numbers when creating syntax-highlighted HTML.
  • wrapper-tag [pre] β€” which tag syntax highlighted HTML will be wrapped in. possible values: div, pre, id and code.
  • wrapper-attribute [class] β€” attribute used for the wrapper tag. possible values: id and class.
  • document-id [lilypond] β€” name applied to the wrapper-attribute. if the three last options use their default settings, the highlighted HTML elements are wrapped in an element <pre class="lilypond"></pre>.
  • linenumbers-id [linenumbers] β€” if linenumbers are exported, this is the name used for the <td> elements.

these variables influence the output of information commands:

  • with-filename β€” prints the filename next to information like version, etc. this is true by default if there is more than one file specified.

πŸ“ EXAMPLES πŸ“

here’s an example to re-indent and transpose a LilyPond file:

ly "indent; transpose c d" -o output.ly file.ly

examples using the * in the output file name:

ly "transpose c d" *.ly -o '*-transposed.ly'
ly highlight *.ly -o 'html/?.html'

πŸ‘‘ AUTHOR πŸ‘‘

Wilbert Berendsen. iconic author energy. 🫢


2025, Wilbert Berendsen.


so yeah, that’s LY(1) from python-ly β€” version 0.9.9, dated Feb 08, 2025. go manipulate some LilyPond, bestie, you’ve got this πŸ’–πŸŽ€βœ¨

πŸ“¦ where this page comes from