forked from openlp/openlp
Check 'end html' instead of 'end tag'
This commit is contained in:
parent
9889f8f33c
commit
14c0c93463
@ -328,7 +328,7 @@ def find_formatting_tags(text, active_formatting_tags):
|
|||||||
# See if the found tag has an end tag
|
# See if the found tag has an end tag
|
||||||
for formatting_tag in FormattingTags.get_html_tags():
|
for formatting_tag in FormattingTags.get_html_tags():
|
||||||
if formatting_tag['start tag'] == '{' + tag + '}':
|
if formatting_tag['start tag'] == '{' + tag + '}':
|
||||||
if formatting_tag['end tag']:
|
if formatting_tag['end html']:
|
||||||
if start_tag:
|
if start_tag:
|
||||||
# prepend the new tag to the list of active formatting tags
|
# prepend the new tag to the list of active formatting tags
|
||||||
active_formatting_tags[:0] = [tag]
|
active_formatting_tags[:0] = [tag]
|
||||||
@ -486,8 +486,12 @@ def get_start_tags(raw_text):
|
|||||||
"""
|
"""
|
||||||
raw_tags = []
|
raw_tags = []
|
||||||
html_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():
|
for tag in FormattingTags.get_html_tags():
|
||||||
if tag['start tag'] == '{br}':
|
if tag['start tag'] in endless_tags:
|
||||||
continue
|
continue
|
||||||
if raw_text.count(tag['start tag']) != raw_text.count(tag['end tag']):
|
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']))
|
raw_tags.append((raw_text.find(tag['start tag']), tag['start tag'], tag['end tag']))
|
||||||
|
@ -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.db import Author, AuthorType, Book, MediaFile, Song, SongBookEntry, Topic
|
||||||
from openlp.plugins.songs.lib.openlyricsxml import SongXML
|
from openlp.plugins.songs.lib.openlyricsxml import SongXML
|
||||||
from openlp.plugins.songs.lib.ui import SongStrings
|
from openlp.plugins.songs.lib.ui import SongStrings
|
||||||
|
from openlp.core.lib.formattingtags import FormattingTags
|
||||||
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
@ -285,8 +286,12 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties):
|
|||||||
"""
|
"""
|
||||||
if first_time:
|
if first_time:
|
||||||
fixed_tags = []
|
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)):
|
for i in range(len(tags)):
|
||||||
if tags[i] != '{br}':
|
if tags[i] not in endless_tags:
|
||||||
fixed_tags.append(tags[i])
|
fixed_tags.append(tags[i])
|
||||||
tags = fixed_tags
|
tags = fixed_tags
|
||||||
if len(tags) == 0:
|
if len(tags) == 0:
|
||||||
|
@ -355,8 +355,12 @@ class OpenLyrics(object):
|
|||||||
{st}{r}Text text text
|
{st}{r}Text text text
|
||||||
"""
|
"""
|
||||||
tags = []
|
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():
|
for tag in FormattingTags.get_html_tags():
|
||||||
if tag['start tag'] == '{br}':
|
if tag['start tag'] in endless_tags:
|
||||||
continue
|
continue
|
||||||
if text.count(tag['start tag']) != text.count(tag['end tag']):
|
if text.count(tag['start tag']) != text.count(tag['end tag']):
|
||||||
tags.append((text.find(tag['start tag']), tag['start tag'], 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
|
# Check if formatting tag contains end tag. Some formatting
|
||||||
# tags e.g. {br} has only start tag. If no end tag is present
|
# tags e.g. {br} has only start tag. If no end tag is present
|
||||||
# <close> element has not to be in OpenLyrics xml.
|
# <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 = self._add_text_to_element('close', element)
|
||||||
element_close.text = etree.CDATA(tag['end html'])
|
element_close.text = etree.CDATA(tag['end html'])
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user