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

Suspended chords #1166

Closed ldelia closed 4 months ago

ldelia commented 4 months ago

Hi, first of all, thanks again for this great library!

It looks like the ChordsOverWordsParser parser doesn't recognize suspended chords correctly. In the example above, instead of seeing Dsus4, the parser parses it as Dsus. Something similar happens when using suspended chords with a bass notation, e.g., Dsus4/G# will be parsed as Dsus/G#.

const chordSheet = `
       Am         C/G        Dsus4          C
Let it be, let it be, let it be, let it be
C                G              F  C/E Dm C
Whisper words of wisdom, let it be`.substring(1);

const parser = new ChordSheetJS.ChordsOverWordsParser();
const song = parser.parse(chordSheet);
martijnversluis commented 4 months ago

Hi @ldelia. Thanks for reaching out.

All formatters should accept the normalizeChords: false option in the constructor, thus disabling normalization. However, that was not properly implemented in all formatters. I released 9.0.3 to fix that issue.

To format your parsed song without chord normalization:

const formatter = new ChordsOverWordsFormatter({ normalizeChords: false }); # Or a different formatter
const formatted = formatter.format(song);

Please let me know if this fixes your issue!

ldelia commented 4 months ago

Hi @martijnversluis, thanks for your quick response. Now, I can see that I opened this ticket wrongly. I should have detailed that I was using the HtmlTableFormatter formatter, and thanks to your message, I can see that adding the { normalizeChords: false } arg in the constructor solves my issue. Everything works like a charm! Thanks!

image