[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

ANN: Pygments support for LilyPond

From: Jean Abou Samra
Subject: ANN: Pygments support for LilyPond
Date: Sun, 21 Nov 2021 23:47:45 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.1

Pygments, a syntax highlighter written in Python,
just received support for LilyPond. This means that,
using the latest version of Pygments, you can get
highlighted LilyPond source in LaTeX documents,
Sphinx documentation, Wordpress sites, the output
of various other tools, and any format you like.
(It's also used on Wikipedia, but we'll have to
wait until a release.) To get the latest Pygments,
the short story is

python3 -m pip install --user

The long story is that you should start by installing
Python. On most GNU/Linux systems, it comes out of the
box or in package managers. On macOS or Windows, download
it from Then, you need
pip to install packages. If you don't have pip yet, do
'sudo apt install python3-pip' on Debian/Ubuntu, or
'python3 -m ensurepip --user' pretty much anywhere. Finally,
run the command above to let pip install Pygments.

Importantly, you must use the 'lilypond' style. Other styles
(such as the default one) will not produce good-looking
output because they don't know about LilyPond's concepts
(grobs, engravers, etc.).

To use with Sphinx, add to your

highlight_language = "lilypond"
pygments_style = "lilypond"

Here is an example of how to use it in LaTeX with the
minted package:





\version "2.23.4"

\header {
  title = \markup \bold "Yes!"

\relative { c' }
\addlyrics { Oh! }

Please report any issues at
and mention me (@Jean-Abou-Samra).

Thanks go to Matthaüs G. Chajdas, one of the two Pygments
maintainers, for reviewing the code, and to Dan Eble and
Jonas Hahnfeld for their feedback.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]