mirror of
https://gitlab.com/parroquia-san-leandro/cancionero-web.git
synced 2024-12-22 00:33:33 +01:00
fixed bug related to loop counter update
This commit is contained in:
parent
9c5602876c
commit
30dc36d262
1 changed files with 4 additions and 19 deletions
|
@ -84,15 +84,16 @@ class SongLoader:
|
|||
text = re.sub(r"\\brk({})?", '', text)
|
||||
|
||||
extras = {}
|
||||
for i in range(len(text)):
|
||||
i = 0
|
||||
while i <= len(text):
|
||||
beginning = text[:i]
|
||||
remain = text[i:]
|
||||
if re.match(r"\\fi", remain):
|
||||
ignore = False
|
||||
text = beginning + text[i + len("\\fi"):]
|
||||
i -= 1
|
||||
continue
|
||||
if ignore:
|
||||
i += 1
|
||||
continue
|
||||
|
||||
# Command lookup
|
||||
|
@ -100,7 +101,6 @@ class SongLoader:
|
|||
if re_transpose_match:
|
||||
text = beginning + text[i + len(re_transpose_match.group(0)):]
|
||||
transpose = int(re_transpose_match.group(1))
|
||||
i -= 1
|
||||
continue
|
||||
re_song_begin_match = re.match(r"\\beginsong *?{(.*?)}(\[.*?])?", remain)
|
||||
if re_song_begin_match:
|
||||
|
@ -120,14 +120,12 @@ class SongLoader:
|
|||
replay_index = 0
|
||||
for a in find_audios(self.index):
|
||||
current_song.add_audio(a)
|
||||
i -= 1
|
||||
continue
|
||||
if re.match(r"\\endsong", remain):
|
||||
text = beginning + text[i + len("\\endsong"):]
|
||||
self.songs.append(current_song)
|
||||
current_song = None
|
||||
self.index += 1
|
||||
i -= 1
|
||||
continue
|
||||
re_verse_cmd_match = re.match(r"\\(begin|end)(verse|chorus)", remain)
|
||||
if re_verse_cmd_match:
|
||||
|
@ -150,33 +148,27 @@ class SongLoader:
|
|||
memorizing = False
|
||||
current_song.add_verse(current_verse)
|
||||
current_verse = None
|
||||
i -= 1
|
||||
continue
|
||||
re_capo_match = re.match(r"\\capo{(\d+?)}", remain)
|
||||
if re_capo_match and current_song:
|
||||
text = beginning + text[i + len(re_capo_match.group(0)):]
|
||||
current_song.set_capo(int(re_capo_match.group(1)))
|
||||
i -= 1
|
||||
continue
|
||||
if re.match(r"\\ifchorded", remain):
|
||||
text = beginning + text[i + len("\\ifchorded"):]
|
||||
i -= 1
|
||||
continue
|
||||
if re.match(r"\\else", remain):
|
||||
ignore = True
|
||||
text = beginning + text[i + len("\\else"):]
|
||||
i -= 1
|
||||
continue
|
||||
re_echo_match = re.match(r"\\echo[ \t]*?{((.|{.*?})*?)}", remain)
|
||||
if re_echo_match:
|
||||
text = beginning + re_echo_match.group(1) + "\\echoend" + text[i + len(re_echo_match.group(0)):]
|
||||
extra_put(extras, i, "echo")
|
||||
i -= 1
|
||||
continue
|
||||
if re.match(r"\\echoend", remain):
|
||||
text = beginning + text[i + len("\\echoend"):]
|
||||
extra_put(extras, i, "echo")
|
||||
i -= 1
|
||||
continue
|
||||
re_chord_match = re.match(r"\\\[(.+?)]", remain)
|
||||
if re_chord_match:
|
||||
|
@ -185,51 +177,44 @@ class SongLoader:
|
|||
extra_put(extras, i, "chord", c)
|
||||
if memorizing:
|
||||
memory.append(c)
|
||||
i -= 1
|
||||
continue
|
||||
if re.match(r"\^", remain):
|
||||
text = beginning + text[i + len("^"):]
|
||||
if memory is not None and replay_index < len(memory):
|
||||
extra_put(extras, i, "chord", memory[replay_index])
|
||||
replay_index += 1
|
||||
i -= 1
|
||||
continue
|
||||
re_dir_rep_match = re.match(r"\\([lr]rep)", remain)
|
||||
if re_dir_rep_match:
|
||||
text = beginning + text[i + len(re_dir_rep_match.group(0)):]
|
||||
extra_put(extras, i, "dir-rep", re_dir_rep_match.group(1))
|
||||
i -= 1
|
||||
continue
|
||||
re_rep_match = re.match(r"\\rep{(\d+?)}", remain)
|
||||
if re_rep_match:
|
||||
text = beginning + text[i + len(re_rep_match.group(0)):]
|
||||
extra_put(extras, i, 'rep', int(re_rep_match.group(1)))
|
||||
i -= 1
|
||||
continue
|
||||
if re.match(r"\\memorize", remain):
|
||||
text = beginning + text[i + len("\\memorize"):]
|
||||
memory = []
|
||||
memorizing = True
|
||||
i -= 1
|
||||
continue
|
||||
if re.match(r"\\replay", remain):
|
||||
text = beginning + text[i + len("\\replay"):]
|
||||
replay_index = 0
|
||||
i -= 1
|
||||
continue
|
||||
# Command lookup end, removing any unrecognized command
|
||||
re_macro_match = re.match(r"\\([^ \t{\[]+)[ \t]*?({.*?}|\[.*?])*", remain)
|
||||
if re_macro_match:
|
||||
text = beginning + text[i + len(re_macro_match.group(0)):]
|
||||
print("Removed an unrecognized command:", re_macro_match.group(0))
|
||||
i -= 1
|
||||
continue
|
||||
i += 1
|
||||
if not current_verse and text.strip() != '':
|
||||
print("l outside v:", text)
|
||||
continue
|
||||
if ignore or text.strip() == '':
|
||||
continue
|
||||
|
||||
current_verse.add_line(Line(text, extras))
|
||||
|
||||
def print_index(self, index_file="index.html"):
|
||||
|
|
Loading…
Reference in a new issue