2.0.2 • Published 2 years ago

js-chordpro v2.0.2

Weekly downloads
1
License
ISC
Repository
github
Last release
2 years ago

ChordPro

Javscript implementation of parser for song lyrics writted in ChordPro format.

The solution is based on wonderful tools nearley parser and moo lexer.

How to build and deploy

Install dependences:

npm install

Compile grammar to js:

npx nearly src/grammar.ns -o src/grammar.js

Start development mode (package is built on each change in source code):

npm run dev

Build package for deploymet:

npm run build

ChordPro Format Coverage

Preamble directives

  • new_song, ns

Meta-data directives

  • title, t
  • subtitle, st
  • artist
  • composer
  • lyricist
  • copyright
  • album
  • year
  • key
  • time
  • tempo
  • duration
  • capo
  • meta

Formatting directives

  • comment, c
  • comment_italic, ci
  • comment_box, cb
  • image

Environment directives

  • start_of_chorus, soc
  • end_of_chorus, eoc
  • chorus
  • start_of_verse
  • end_of_verse
  • start_of_tab, sot)
  • end_of_tab, eot)
  • start_of_grid
  • end_of_grid

Chord diagrams

  • define
  • chord

Fonts, sizes and colours

  • textfont
  • textsize
  • textcolour
  • chordfont
  • chordsize
  • chordcolour
  • tabfont
  • tabsize
  • tabcolour

Output related directives

  • new_page, np
  • new_physical_page, npp)
  • column_break, cb

  • grid, g

  • no_grid, ng
  • titles
  • columns, col

Custom extensions

  • x_

Quick Start

var chordpro = require('js-chordpro');

// Song to be parsed
const song_chordpro = `
{title: Some Song}

[G]This is first [C]verse
with [G]chords
`;

// tokenize and parse song into in-memory song document structure
let parsed = jschordpro.parse(song_chordpro + "\n")

// render in-memory song document to html
let html = jschordpro.to_html(doc);

console.log(html);

Use as cli tool

Package provides cli command jschordpro.

Following command will register package as cli command in case you don't install it as npm package (e.g. in case of git clone)

npm link

Resources

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago