LilyPond (sheet music typesetting) integration

AnkiWeb addon 1080109152

Renders LilyPond sheet music in Anki cards using [lilypond] tags or -lilypond fields, with customizable templates and a -lilypondimg workaround for mobile/web.
AI-generated summary; may contain mistakes.

card-creationmobile-compatible

Open on AnkiWeb GitHub Ask about alternatives

AnkiWeb

Rating
0 (πŸ‘ 0 Β· πŸ‘Ž 0)
Updated
2021-09-28
Anki versions
2.1.43~
Description language
en

Maintenance

abandoned

  • Last update or commit was 1829 days before the snapshot (2021-09-28).

Will it work on my Anki?

Version branches
Min AnkiMax AnkiUpdated
2.1.352.1.43+2021-09-28
History across monthly snapshots

Loading…

Similar addons

Anki 2 Google Sheets Instant Export

Exports selected Anki Browser notes one-way to a specific Google Sheets sheet, with customizable fields, append/replace modes, HTML stripping, and optional Anki CSV headers.

exportsync-integration

Rating 0 πŸ‘ 0 Β· πŸ‘Ž 0 Anki 2.1.1~ Updated 2026-02-08

README

LilyPond integration for Anki

Add sheet music snippets to your Anki deck, wrapped in [lilypond][/lilypond] tags.

This addon requires LilyPond in order to work.

How to use

  • Wrap inline LilyPond code in tags:

    [lilypond]c d e[/lilypond]
    
  • Create fields for LilyPond code with -lilypond at the end of the field's name, e.g. front-lilypond or back-lilypond. The entire contents of which will be rendered, tags not required:

    c d e
    
  • Create fields for LilyPond code and put [lilypond][/lilypond] tags around them in the card template. This is not recommended as music will be re-rendered every time the card is shown.

Please refer to the LilyPond homepage and documentation for details on how to write LilyPond code.

Templates

The styling of LilyPond output is controlled by templates. The default template looks like this:

\paper{
  indent=0\mm
  line-width=120\mm
  oddFooterMarkup=##f 
  oddHeaderMarkup=##f 
  bookTitleMarkup = ##f 
  scoreTitleMarkup = ##f 
}

{ %ANKI% }

Where %ANKI% will be replaced with the code to be rendered.

You can add your own templates to the user_files directory in the addon's files (see Tools -> Addons -> LilyPond Integration -> View Files). You'll need to restart Anki after making any changes. Also note that if you want to use LilyPond's \include directive you'll need to provide to full path to the file.

To use a template called exampleTemplate:

  • In inline tags:
    [lilypond=exampleTemplate]c d e[/lilypond]
    
  • In a LilyPond field add -exampleTemplate to the end of the field's name, e.g. front-lilypond-exampleTemplate.

Multi-part templates

You can create a template with multiple occurrences of %ANKI%, then separate sections of code with %%% which will then be substituted in to the corresponding occurrences.

For example with the LilyPond code

c d e
%%%
f g a

the first occurrence of %ANKI% in the template will be replaced with c d e, and the second occurrence of %ANKI% with will be replaced with f g a.

Surplus occurrences of %ANKI% in the template will be left as-is (which will cause errors in LilyPond). Surplus sections of code will be ignored.

Mobile/Web support

Anki addons are desktop only, so by default, LilyPond images won't appear on other platforms since those platforms won't know what to make of a [lilypond] tag or how to treat a -lilypond field.

As a workaround you can use LilyPond fields and for each field create another field with the same name but ending with -lilypondimg. The desktop addon will replace the contents of this field with the rendered image. You can then use this field in your notes.

For example, if your field is front-lilypond, with content c d e, create the field front-lilypondimg and use the front-lilypondimg field in your card template wherever you want the rendered music to appear. As long as you create your cards on desktop so that the plugin can generate the image this image will then be visable on all platforms.

Note that the contents of the -lilypondimg field will be overwritten so don't put anything important in there.

ToDo

  • [x] Configuration parameters for lilypond executable
  • [ ] Config options for <img> HTML tag attributes (alt, etc.)
  • [ ] Menu integration (for templates?)
  • [ ] Menu option to regenerate all images (also reload templates)
  • [x] Use .ily files for templates
  • [ ] Allow simple pathnames for \include-s in templates