chordpro-parser
Version:
Chordpro Parser based on the chordsheejs module
28 lines (24 loc) • 756 B
JavaScript
const ChordSheetJS = require('chordsheetjs').default;
const format = {
HTML: "html",
HTML_DIV: "htmldiv",
HTML_TABLE: "htmltable",
TEXT: "text"
};
module.exports.parse = function(chordproSheet, returnFormat) {
const parser = new ChordSheetJS.ChordProParser();
const song = parser.parse(chordproSheet);
returnFormat = (typeof returnFormat === 'undefined' ) ? format.TEXT : returnFormat.toLowerCase();
var formatter;
switch (returnFormat) {
case "html","htmldiv":
formatter = new ChordSheetJS.HtmlDivFormatter();
break;
case "htmltable":
formatter = new ChordSheetJS.HtmlTableFormatter();
break;
default:
formatter = new ChordSheetJS.TextFormatter();
}
return formatter.format(song);
}