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

ChordProParser #469

Closed ezracb closed 2 years ago

ezracb commented 2 years ago

I use this example,

const chordSheet = '
       Am         C/G        F           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.ChordSheetParser(); const song = parser.parse(chordSheet);`

And then i try to convert and display the result like this

const formatter = new ChordSheetJS.ChordProFormatter();
const disp = formatter.format(song);

What I was hoping is resulting this

Let it [Am]be, let it [C/G]be, let it [F]be, let it [C]be
[C]Whisper words of [G]wisdom, let it [F]be [C/E] [Dm] [C]

However it is resulting like this

[      ]Let it [Am        ]be, let it [C/G       ]be, let it [F         ]be, let it [C]be
[C               ]Whisper words of [G             ]wisdom, let it [F ]be[C/E][Dm][C]

Why is there any blank space on the fron of 'Let' also every note there is a space inside the box?

martijnversluis commented 2 years ago

Hey @ezracb. Thanks for reaching out!

This looks like a serious bug. I'll look into this and keep you posted 👍

martijnversluis commented 2 years ago

Quick update: there is an opt-in setting preserveWhitespace: false which you can pass to the parser like below:

const parser = new ChordSheetJS.ChordSheetParser({ preserveWhitespace: false });

This will make the chordpro output look (almost) like expected.

I'll have to determine whether it should be an opt-out setting instead.

ezracb commented 2 years ago

Yes it solved my issue, Thanks..