martijnversluis / ChordSheetJS

A JavaScript library for parsing and formatting ChordPro chord sheets
https://github.com/users/martijnversluis/projects/4
GNU General Public License v2.0
311 stars 48 forks source link

Chords mid-word separate words #1267

Open kriztho opened 1 month ago

kriztho commented 1 month ago

Hi Martijn, I'm very grateful for your work on this project. It's been blessing my Music Ministry at Church immensely. I don't know if this is the right way to contact you for support. Please let me know if I need to do it differently.

The problem is illustrated in the following screenshot: Screenshot 2024-07-24 at 2 51 04 PM

When I have the chords matching the first letter of words, the library does the right job and no words are broken half-way. This is the case in the top paragraph of the screenshot.

However, when chords are placed atop of any other letter but the first, then the word is broken apart, which is of course, undesired.

I'm using the following CSS: .row { display: flex;
flex-wrap: wrap; gap: 5px; }

If I remove the gap: 5px to help with the spaces, I of course run into the following situation, where words are not broken apart when chords are placed other than the first letter, but then when chords have no matching lyrics, then all chords are smushed together which renders them hard to read.

Screenshot 2024-07-24 at 2 53 14 PM

Is there anyway to fix this? Am I doing something wrong? This is my logic below:

// ChordSheetJS is available in global namespace now const formatter = new ChordSheetJS.HtmlDivFormatter(); var song;

function loadSong(id) { chordSheet = document.getElementById(id).textContent.substring(1); parser = new ChordSheetJS.ChordsOverWordsParser(); song = parser.parse(chordSheet); display = formatter.format(song); document.getElementById("display").innerHTML = display; }

Cris

adriaanzon commented 1 week ago

I noticed this too after I (long overdue) updated ChordsheetJS to its latest version. This behavior seems to have been introduced in PR https://github.com/martijnversluis/ChordSheetJS/pull/654.

Here's what it looks like before and after updating:

image image

It is especially noticeable in text that uses many short words as demonstrated above, or when placing a chord directly in front of a space.