Remove chords from the slide controller and the display

This commit is contained in:
Raoul Snyman 2019-08-29 14:08:37 -07:00
parent 302736357a
commit eed89c4024
2 changed files with 13 additions and 2 deletions

View File

@ -67,6 +67,15 @@ FOOTER_COPYRIGHT = 'Public Domain'
CCLI_NO = '123456' CCLI_NO = '123456'
def remove_chords(text):
"""
Remove chords from the text
:param text: Text to be cleaned
"""
return re.sub(r'\[.+?\]', r'', text)
def remove_tags(text, can_remove_chords=False): def remove_tags(text, can_remove_chords=False):
""" """
Remove Tags from text for display Remove Tags from text for display
@ -82,7 +91,7 @@ def remove_tags(text, can_remove_chords=False):
text = text.replace(tag['end tag'], '') text = text.replace(tag['end tag'], '')
# Remove ChordPro tags # Remove ChordPro tags
if can_remove_chords: if can_remove_chords:
text = re.sub(r'\[.+?\]', r'', text) text = remove_chords(text)
return text return text
@ -377,6 +386,8 @@ def render_tags(text, can_render_chords=False, is_printing=False):
text = render_chords_for_printing(text, '{br}') text = render_chords_for_printing(text, '{br}')
else: else:
text = render_chords(text) text = render_chords(text)
else:
text = remove_chords(text)
for tag in FormattingTags.get_html_tags(): for tag in FormattingTags.get_html_tags():
text = text.replace(tag['start tag'], tag['start html']) text = text.replace(tag['start tag'], tag['start html'])
text = text.replace(tag['end tag'], tag['end html']) text = text.replace(tag['end tag'], tag['end html'])

View File

@ -185,7 +185,7 @@ class ServiceItem(RegistryProperties):
self._rendered_slides.append(rendered_slide) self._rendered_slides.append(rendered_slide)
display_slide = { display_slide = {
'title': raw_slide['title'], 'title': raw_slide['title'],
'text': remove_tags(page), 'text': remove_tags(page, can_remove_chords=True),
'verse': verse_tag, 'verse': verse_tag,
} }
self._display_slides.append(display_slide) self._display_slides.append(display_slide)