Check 'end html' instead of 'end tag'

This commit is contained in:
STEPHANVS 2021-09-10 23:49:55 +02:00
parent 9889f8f33c
commit 14c0c93463
No known key found for this signature in database
GPG Key ID: 4EFE47E471FD62A9
3 changed files with 18 additions and 5 deletions

View File

@ -328,7 +328,7 @@ def find_formatting_tags(text, active_formatting_tags):
# See if the found tag has an end tag
for formatting_tag in FormattingTags.get_html_tags():
if formatting_tag['start tag'] == '{' + tag + '}':
if formatting_tag['end tag']:
if formatting_tag['end html']:
if start_tag:
# prepend the new tag to the list of active formatting tags
active_formatting_tags[:0] = [tag]
@ -486,8 +486,12 @@ def get_start_tags(raw_text):
"""
raw_tags = []
html_tags = []
endless_tags = []
for formatting_tag in FormattingTags.get_html_tags():
if not formatting_tag['end html']:
endless_tags.append(formatting_tag['start tag'])
for tag in FormattingTags.get_html_tags():
if tag['start tag'] == '{br}':
if tag['start tag'] in endless_tags:
continue
if raw_text.count(tag['start tag']) != raw_text.count(tag['end tag']):
raw_tags.append((raw_text.find(tag['start tag']), tag['start tag'], tag['end tag']))

View File

@ -45,6 +45,7 @@ from openlp.plugins.songs.lib import VerseType, clean_song
from openlp.plugins.songs.lib.db import Author, AuthorType, Book, MediaFile, Song, SongBookEntry, Topic
from openlp.plugins.songs.lib.openlyricsxml import SongXML
from openlp.plugins.songs.lib.ui import SongStrings
from openlp.core.lib.formattingtags import FormattingTags
log = logging.getLogger(__name__)
@ -285,8 +286,12 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties):
"""
if first_time:
fixed_tags = []
endless_tags = []
for formatting_tag in FormattingTags.get_html_tags():
if not formatting_tag['end html']:
endless_tags.append(formatting_tag['start tag'])
for i in range(len(tags)):
if tags[i] != '{br}':
if tags[i] not in endless_tags:
fixed_tags.append(tags[i])
tags = fixed_tags
if len(tags) == 0:

View File

@ -355,8 +355,12 @@ class OpenLyrics(object):
{st}{r}Text text text
"""
tags = []
endless_tags = []
for formatting_tag in FormattingTags.get_html_tags():
if not formatting_tag['end html']:
endless_tags.append(formatting_tag['start tag'])
for tag in FormattingTags.get_html_tags():
if tag['start tag'] == '{br}':
if tag['start tag'] in endless_tags:
continue
if text.count(tag['start tag']) != text.count(tag['end tag']):
tags.append((text.find(tag['start tag']), tag['start tag'], tag['end tag']))
@ -450,7 +454,7 @@ class OpenLyrics(object):
# Check if formatting tag contains end tag. Some formatting
# tags e.g. {br} has only start tag. If no end tag is present
# <close> element has not to be in OpenLyrics xml.
if tag['end tag']:
if tag['end html']:
element_close = self._add_text_to_element('close', element)
element_close.text = etree.CDATA(tag['end html'])