#Songbeamer parser
This little utility parses a songbeamer file into the beaneath described structure. ##Usage
const songbeamer = require('songbeamer');
try{
songbeamer(data); //Data has to be string of songbeamer file in UTF-8
}catch(e){
console.log(e.msg, e.data); // e.msg is the error message, e.data are variables passed as additional informations
}
{
props: {
name: value,
...
}
texts: { // Contains Verses as array
verseName: [ //Verse: Contains slides as array
[ //Slide: contains lines as array
[ // Line: contains translations as string
"Text ...",
...
]
...
]
...
]
}
}
name and value are represeting key-value-pairs as in the upper section of the songbeamer file. The most properties are stored as strings matching the content of the sng file, but the following exceptions are handled different:
Will be stored in an Array under the name Title
"Title": [Title, TitleLang1, TitleLang2, ..., TitleLangN]
Will be stored in an Array with a comma as seperator. If this is not defined in the file, it will be created and generated by the songtext. For this the first line of every verse is used and will be set as the name of the verse. If this is one of the Tags specified in songbeamer wiki, the line will be removed from songtext otherwise it is kept in the text.
Is stored in base64 encoding, this utility will decode it to normal string.
Is stored in base64 encoding, this utility will decode it to normal string. Afterwards it is splitted into an array (seperator is "\r")
Is splitted into an array (seperator is " ")
Is splitted into an array (seperator is ",")
Will be returned the same as in the file, except the strings is a color ("color://$00000000"), then it will be saved as:
"BackgroundColor": {rgb: val}
"val" is the parsed hex color value ANDed with 0xFFFFFF and thereby represents an rgb value. The first byte of the songbeamer file color string has yet unknown functionality.
Is renamed to Copyright
Values from theese keys will be parsed as integers.
Is an associative array (object) of verses, how the key is determined is described in props:VerseOrder. Each verse is an array containing slides, each slide is also an array containing lines, each line is also an array containing different translations. The first translation is the main language (may be defined in props["Lang"]).
Usually in every line of a song there should be the same number of translations, but the last/only lines of a slide may contain less. This is either due to a malformed file or (if the line contains one translation) it could also mean that every language contains this last line. This behaviour was watched often in cases like "2x" or "(3x)", of course this make sense to be shown in every translation.
- Official Songbeamer manual, is not really extensive
- Songbeamer file format descriptions