Import songs provided on disks with the Songs of Fellowship music books VOLS1_2.RTF, sof3words.rtf and sof4words.rtf
Use OpenOffice.org Writer for processing the rtf file
The three books are not only inconsistent with each other, they are inconsistent in themselves too with their formatting. Not only this, but the 1+2 book does not space out verses correctly. This script attempts to sort it out, but doesn’t get it 100% right. But better than having to type them all out!
It attempts to detect italiced verses, and treats these as choruses in the verse ordering. Again not perfect, but a start.
Add the author. OpenLP stores them individually so split by ‘and’, ‘&’ and comma. However need to check for “Mr and Mrs Smith” and turn it to “Mr Smith” and “Mrs Smith”.
Parameters: text – Author text
Add a song number, store as alternate title. Also use the song number to work out which songbook we’re in
Parameters: song_no – The Song number
Add the title to the song. Strip some leading/trailing punctuation that we don’t want in a title
Parameters: text – Title text
Add a line to the current verse. If the formatting has changed and we’re beyond the second line of first verse, then this indicates a change of verse. Italics are a chorus
Parameters: text – The verse text
Verse is finished, store it. Note in book 1+2, some songs are formatted incorrectly. Here we try and split songs with missing line breaks into the correct number of verses.
A change of song. Store the old, create a new … but only if the last song was complete. If not, stick with it
Handle the import process for SoF files.
Process a paragraph. In the first book, a paragraph is a single line. In the latter ones they may contain multiple lines. Each paragraph contains textportions. Each textportion has it’s own styling, e.g. italics, bold etc. Also check for page breaks, which indicates a new song in books 1+2. In later books, there may not be line breaks, so check for 3 or more newlines
Parameters: paragraph – The paragraph text
Process a single line. Throw away that text which isn’t relevant, i.e. stuff that appears at the end of the song. Anything that is OK, append to the current verse
Parameters: text – The text
Split the paragraph text into multiple lines and process
Parameters: text – The text
Process the RTF file, a paragraph at a time
Process a text portion. Here we just get the text and detect if it’s bold or italics. If it’s bold then its a song number or song title. Song titles are in all capitals, so we must bring the capitalization into line
Parameters: text_portion – A Piece of text
Words in the title are in all capitals, so we lowercase them. However some of these words, e.g. referring to God need a leading capital letter.
There is a complicated word “One”, which is sometimes lower and sometimes upper depending on context. Never mind, keep it lower.
Because someone at Kingsway forgot to check the 1+2 RTF file, some verses were not formatted correctly.
Parameters: song_number – The Song number