Fix, implement support ${D=}...${D!} block syntax for DC_S lyrics
This commit is contained in:
parent
d6c7b70792
commit
fcebf2ebdf
1 changed files with 19 additions and 4 deletions
|
|
@ -63,6 +63,8 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository
|
|||
val REGEX_NOTE_TODROP = Regex("([drmfsltz][ia]?|[―])([₄₃₂₁¹²³⁴',]*)<")
|
||||
val REGEX_NOTE_SPLIT = Regex("\\$\\{[Ss]:([^\\}]+)\\}([drmfsltDRFSTz][,']*)")
|
||||
val REGEX_DC_REFRAIN = Regex("""\$\{R=\}\$\{D:(.*?)\}""")
|
||||
val REGEX_D_BLOCK = Regex("""\$\{D=\}(.*?)\$\{D!\}""", RegexOption.DOT_MATCHES_ALL)
|
||||
val REGEX_OVERRIDE_TOKEN = Regex("""\$\{O:\d+\}""")
|
||||
val KEEP_MARKERS = listOf("\${L}", "\$T")
|
||||
}
|
||||
|
||||
|
|
@ -2171,13 +2173,13 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository
|
|||
loadM(value)
|
||||
|
||||
"L" ->
|
||||
loadL(index, value)
|
||||
loadL(index, normalizeDBlocks(value))
|
||||
|
||||
"Y" ->
|
||||
loadY(index, value)
|
||||
loadY(index, normalizeDBlocks(value))
|
||||
|
||||
"E" ->
|
||||
loadE(index, value)
|
||||
loadE(index, normalizeDBlocks(value))
|
||||
|
||||
"U" ->
|
||||
loadU(value)
|
||||
|
|
@ -2812,6 +2814,7 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository
|
|||
val isDS = Regex("\\$\\{D([^:]*):").find(item)
|
||||
if (isDS != null) {
|
||||
item = item.replace(REGEX_LYRICS_COMMENT, "$2")
|
||||
item = decodeNestedBraces(item) // restitue les ${O:n} imbriqués
|
||||
val signDS = isDS.groupValues[1]
|
||||
val item = when (smartLyricsType) {
|
||||
"E" -> smartELyrics(item.replace(" _", " "))
|
||||
|
|
@ -2826,7 +2829,8 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository
|
|||
.addHyphens()
|
||||
.split(Regex("[_/]"))
|
||||
.forEachIndexed { i, xval ->
|
||||
appendLyricsItem(stanzaNumber, i + pDS, xval)
|
||||
// ${O:n} imbriqués sont retirés
|
||||
appendLyricsItem(stanzaNumber, i + pDS, REGEX_OVERRIDE_TOKEN.replace(xval, ""))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2903,6 +2907,17 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository
|
|||
return REGEX_STRIP_DC.replace(lyrics, $$"\\${x:}")
|
||||
}
|
||||
|
||||
fun normalizeDBlocks(lyrics: String): String =
|
||||
REGEX_D_BLOCK.replace(lyrics) { m ->
|
||||
"\${D:${encodeNestedBraces(m.groupValues[1])}}"
|
||||
}
|
||||
|
||||
private fun encodeNestedBraces(inner: String): String =
|
||||
inner.replace("\${", "\uE000").replace('}', '\uE001')
|
||||
|
||||
private fun decodeNestedBraces(text: String): String =
|
||||
text.replace("\uE000", "\${").replace('\uE001', '}')
|
||||
|
||||
private fun defineRefrainFrom(tuoNumber: Int) {
|
||||
refrainBeginsAt = tuoNumber
|
||||
refrainEndsAt = 99999
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue