Skip to content

Add support for lyrics markup and annotations#161

Open
berniyh wants to merge 16 commits into
nullobsi:mainfrom
berniyh:lyrics_markup
Open

Add support for lyrics markup and annotations#161
berniyh wants to merge 16 commits into
nullobsi:mainfrom
berniyh:lyrics_markup

Conversation

@berniyh

@berniyh berniyh commented Jul 26, 2026

Copy link
Copy Markdown

Note that this is built on top of #160. Just can't compare against that branch while submitting the PR to your repository. So only the last 5 commits 53712e7..012a3cd are relevant here.

I put these 5 commits into a new PR, because they are a bit more invasive than the previous commits. That's mainly, because to handle the metadata, we create a new lyrics metadata json file that sits in cache. This can contain links, markups, annotation references and possibly more. Without the json, a lyrics file loaded from disk would have no source. On the other hand, we don't want to save to the lyrics file to avoid breaking other programs.

Here are the added features in detail:

  1. Show a source link to the lyrics we fetched. In my opinion this should be obligatory.
  2. If the lyrics provider uses headers, e.g. for sections, render them as such, making for a more structured appearance. Because I can't check every provider, I made this optional, but in principle it could work for other providers. I don't think I've seen one other than Genius that does this, so I only enabled it for that one.
  3. Genius provides annotations that can be viewed for certain parts of the lyrics. I find those very helpful to better understand the meaning behind the lyrics. I thought it'd be pretty cool to actually show them in Cantata as well, which is why I added lyricsmarkup.cpp, which can handled fetching and rendering of the annotations. Annotations are highlighted by underlining them and opened as inserted, offset text when clicked.

I already attempted an implementation of the annotations feature last year, but back then I did it by rendering it in an actual webpage, which created a bit of a mess, so I decided to drop it. The new approach is less invasive, cleaner and it properly works (at least with all the things that I tested so far). I still think that having proper html5 capability could be beneficial. e.g. could highlight using color marks like Genius itself does it or to show the voting on annotations. If you think so, too, that could be part of future work.

Note that again, I implemented this using Claude Opus 5. I tried to review the code to the best of my abilities.

Bernd Steinhauser added 16 commits July 26, 2026 09:25
This allows to fetch from providers like genius
that spread lyrics across multiple containers.
This was likely done to remove trailing whitespace,
but in some cases it will actually drop the last
character of the actual lyrics.
The code runs trimmed(), which will remove trailing
whitespace, so it shouldn't be required anyways.
This is done by saving metadata to a json file in cache.
If this file exists, we check if it was created at the same
time as the lyrics file, i.e. the simplest way to check if
it is stale.

If the file exists and is valid, attempt to load the provider
and url from it and show that in the lyrics page.
Gated by a markup option, since I can't test every provider,
so this seemed to be the safe route.
Guided by an option, this allows to indicate and
show available annotations for the loaded lyrics.
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

Successfully merging this pull request may close these issues.

1 participant