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

Support using metadata in chord sheet #46

Closed martijnversluis closed 3 years ago

martijnversluis commented 6 years ago

https://web.archive.org/web/20181124024446/http://www.chordpro.org:80/chordpro/ChordPro-Configuration-Format-Strings.html

kahunacohen commented 4 years ago

Hi I would be willing to take this on and issue PRs. As I understand it this ticket means we want the option to display meta data in the output by allowing the formatters to optionally display them.

What API do you suggest? How about an option object passed to the formatter that indicates what meta data we want included:

{capo: true, ...}

etc.

martijnversluis commented 4 years ago

Hi @kahunacohen. Thanks for offering your help on this! ๐ŸŽ‰

The functionality described in this issue is actually a bit different from what you're suggesting, but I would love to have both implemented:

Which one of this were you planning to pick up?

The API you suggest for rendering (in the header I assume?) seems logical. Something like:

formatter.format(song, {
  metadata: {
    capo: true,
    key: true
  }
});

or perhaps using an array:

formatter.format(song, {
  metadata: ['capo', 'key']
});

I'm available for discussion about or help on implementing this, thanks for reaching out!

kahunacohen commented 4 years ago

Not super familiar with chordpro spec. My use-case is that I want meta data like capo rendered in the output. I assume in the beginning, so the header I guess. I assume for HTML this would output classes or ids so the end user can style as they see fit.

I like using the array better than my idea.

martijnversluis commented 4 years ago

My use-case is that I want meta data like capo rendered in the output. I assume in the beginning, so the header I guess. I assume for HTML this would output classes or ids so the end user can style as they see fit.

Agree, sounds like a plan ๐Ÿ‘

I like using the array better than my idea.

Cool ๐Ÿ‘

Do you need something from me to get started?

kahunacohen commented 4 years ago

Nope, gonna for for it as soon as I get a chance.

kahunacohen commented 4 years ago

Taking a look at the simple text formatter. How for example should capo be? As simple as this?

Also do we really need to pass a meta data object to formatter? Why not just always output all metadata, or are there enough use-cases where users might not want specific pieces of metadata in their output?

LET IT BE
ChordSheetJS example version
Capo: 3

Bridge

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

Am               Bb             F  C
Whisper words of wisdom, let it be
martijnversluis commented 4 years ago

@kahunacohen Jep, this looks fine by me. I think displaying it should be configurable as it otherwise might break peopleโ€™s apps. But we can simplify at first it by just exposing one config option? Something like renderMetadata?

kahunacohen commented 4 years ago

Hi, after looking into my project needs I decided to go with Django on the back-end so will either be looking for solutions or building my own python solution. I just can't find a nodejs backend framework that gives me what I want. Thanks.