@@ -331,7 +331,8 @@ const browserPrefersDark = () => {
331331const mailto = ( address ) => window . location . href = 'mailto:' + address ;
332332
333333// build OpenLyrics XML for given song
334- const openLyricsXML = ( song , version , locales = [ ] , allTags = null ) => {
334+ // see https://manual.openlp.org/display_tags.html#configuring-formatting-tags
335+ const openLyricsXML = ( song , version , translatedSong = null , locales = [ ] , allTags = null ) => {
335336 const timestamp = ( new Date ( ) ) . toISOString ( ) . slice ( 0 , - 5 ) ;
336337 const title = `<title>${ song . title } </title>` ;
337338 const subtitle = song . subtitle ? `<title>${ song . subtitle } </title>` : '' ;
@@ -345,16 +346,23 @@ const openLyricsXML = (song, version, locales = [], allTags = null) => {
345346 : '' ;
346347 const tags = song . tags && locales && allTags
347348 ? '<themes>' + song . tags . map (
348- tag => locales . map ( l => `<theme lang=" ${ l } " >${ allTags [ tag ] [ l ] ?? tag . key } </theme>` ) . join ( '' )
349+ tag => locales . map ( l => `<theme lang=' ${ l } ' >${ allTags [ tag ] [ l ] ?? tag . key } </theme>` ) . join ( '' )
349350 ) . join ( '' ) + '</themes>'
350351 : '' ;
351- const lyrics = parsedContent ( song . content , song . tuning , false , false ) . map ( p => {
352+ const format = translatedSong
353+ ? `<format><tags application='OpenLP'><tag name='it'><open><![CDATA[<em>]]></open><close><![CDATA[</em>]]></close><hidden><![CDATA[False]]></hidden></tag><tag name='gr'><open><![CDATA[<span style='-webkit-text-fill-color:grey'>]]></open><close><![CDATA[</span>]]></close><hidden><![CDATA[True]]></hidden></tag><tag name='fd'><open><![CDATA[<small>]]></open><close><![CDATA[</small>]]></close><hidden><![CDATA[True]]></hidden></tag></tags></format>`
354+ : '' ;
355+ const tParts = translatedSong ? parsedContent ( translatedSong . content , 0 , false , false ) : [ ] ;
356+ const lyrics = parsedContent ( song . content , 0 , false , false ) . map ( ( p , i ) => {
352357 const type = p . type ? p . type . toUpperCase ( ) : 'V' ;
353358 const num = p . number > 0 ? p . number : '1' ;
354- return `<verse name='${ type } ${ num } '><lines>` + p . content . replace ( / \n / g, "<br />" ) + '</lines></verse>'
359+ const tContent = ( i in tParts )
360+ ? `<br/><br/><tag name='it'><tag name='gr'><tag name='fd'>${ tParts [ i ] . content . replace ( / \n / g, "<br />" ) } </tag></tag></tag>`
361+ : '' ;
362+ return `<verse name='${ type } ${ num } '><lines>${ p . content . replace ( / \n / g, "<br />" ) } ${ tContent } </lines></verse>` ;
355363 } ) . join ( '' ) ;
356364
357- return `<?xml version='1.0' encoding='UTF-8'?><song xmlns='http://openlyrics.info/namespace/2009/song' version='0.9' createdIn='SongDrive ${ version } ' modifiedIn='SongDrive ${ version } ' modifiedDate='${ timestamp } '><properties><titles>${ title } ${ subtitle } </titles>${ copyright } ${ year } ${ ccli } ${ authors } ${ tags } </properties><lyrics>${ lyrics } </lyrics></song>` ;
365+ return `<?xml version='1.0' encoding='UTF-8'?><song xmlns='http://openlyrics.info/namespace/2009/song' version='0.9' createdIn='SongDrive ${ version } ' modifiedIn='SongDrive ${ version } ' modifiedDate='${ timestamp } '><properties><titles>${ title } ${ subtitle } </titles>${ copyright } ${ year } ${ ccli } ${ authors } ${ tags } </properties>${ format } <lyrics>${ lyrics } </lyrics></song>` ;
358366} ;
359367
360368export {
0 commit comments