Skip to content

Extended directive support

Compare
Choose a tag to compare
@martijnversluis martijnversluis released this 28 Mar 08:55
· 993 commits to master since this release

This release multiple additions to the directive support:

Wrap paragraphs in tags

Use paragraph type in html formatters

This changes the HTML formatters to render per paragraph. It adds a CSS
class when the paragraph type can be determined from usage of
{start_of_verse}, {end_of_verse}, {start_of_chorus} or {end_of_chorus}.

Add support for {meta: key value} directive format

See: https://www.chordpro.org/chordpro/Directives-meta.html

Add support for more metadata directives

When using the ChordProParser, all official meta data directives are parsed and accessible as properties on the parsed song. For example:

const chordSheet = `
{title: Let it be}
{artist: The Beatles}

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]`.substring(1);

const parser = new ChordSheetJS.ChordProParser();
const song = parser.parse(chordSheet);

console.log(song.title);  // Prints "Let it be"
console.log(song.artist); // Prints "The Beatles"

Support is added for:

  • artist
  • composer
  • lyricist
  • copyright
  • album
  • year
  • key
  • time
  • tempo
  • duration
  • capo

See: https://www.chordpro.org/chordpro/ChordPro-Directives.html#meta-data-directives

Allow multiple values for meta data directives

For example, for a chord sheet:

{composer: John}
{composer: Jane}

song.composer will return ['John', 'Jane']

Correctly handle custom meta data

All meta data directives with a name starting with x_ are stored in
song.metaData

See https://www.chordpro.org/chordpro/ChordPro-Directives.html#custom-extensions.