ChordPro format parser
npm install js-chordproJavscript implementation of parser for song lyrics writted in ChordPro format.
Install dependences:
``bash`
npm install`
Compile grammar to js: `
npm run grammar`
Start development mode (package is built on each change in source code):bash`
npm run dev`
Build package for deploymet:bash`
npm run build
Preamble directives
- [ ] new_song, ns
Meta-data directives
- [x] title, t, meta: titlesubtitle
- [x] , startist
- [x] , meta: artistcomposer
- [x] , meta: composerlyricist
- [x] , meta: lyricistcopyright
- [x] , meta: copyrightalbum
- [x] , meta: albumyear
- [x] , meta: yearkey
- [x] , meta: keytime
- [x] , meta: timetempo
- [x] , meta: tempoduration
- [x] , meta: durationcapo
- [x] , meta: capometa
- [ ]
Formatting directives
- [x] comment, ccomment_italic
- [ ] , cicomment_box
- [ ] , cbimage
- [ ]
Environment directives
- [x] start_of_chorus, socend_of_chorus
- [x] , eocchorus
- [ ] start_of_verse
- [ ] end_of_verse
- [ ] start_of_tab
- [x] , sot)end_of_tab
- [x] , eot)start_of_grid
- [ ] end_of_grid
- [ ]
Chord diagrams
- [ ] definechord
- [ ]
Fonts, sizes and colours
- [ ] textfonttextsize
- [ ] textcolour
- [ ] chordfont
- [ ] chordsize
- [ ] chordcolour
- [ ] tabfont
- [ ] tabsize
- [ ] tabcolour
- [ ]
Output related directives
- [ ] new_page, npnew_physical_page
- [ ] , npp)column_break
- [ ] , cb
- [ ] grid, gno_grid
- [ ] , ngtitles
- [ ] columns
- [ ] , col
Custom extensions
- [ ] x_
`javascript
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)
// 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
- https://medium.com/netscape/a-guide-to-create-a-nodejs-command-line-package-c2166ad0452e