forked from openlp/openlp
final fixes and clean ups
This commit is contained in:
parent
4c869fa1f5
commit
3c3339f114
@ -440,21 +440,41 @@ class Renderer(object):
|
|||||||
log.debug(u'_paginate_slide_words - End')
|
log.debug(u'_paginate_slide_words - End')
|
||||||
return formatted
|
return formatted
|
||||||
|
|
||||||
def _get_start_tags(self, text):
|
def _get_start_tags(self, raw_text):
|
||||||
missing_raw_tags = []
|
"""
|
||||||
missing_html_tags = []
|
Tests the given text for not closed formatting tags and returns a tuple
|
||||||
|
consisting of two unicode strings::
|
||||||
|
|
||||||
|
(u'{st}{r}', u'<strong><span style="-webkit-text-fill-color:red">')
|
||||||
|
|
||||||
|
The returned strings can be prepended to the next slide. The first
|
||||||
|
unicode string are OpenLP's formatting tags and the second unicode
|
||||||
|
string the html formatting tags.
|
||||||
|
|
||||||
|
``raw_text``
|
||||||
|
The text to test. The text must **not** contain html tags, only
|
||||||
|
OpenLP formatting tags are allowed.
|
||||||
|
"""
|
||||||
|
raw_tags = []
|
||||||
|
html_tags = []
|
||||||
for tag in FormattingTags.get_html_tags():
|
for tag in FormattingTags.get_html_tags():
|
||||||
if tag[u'start html'] == u'<br>':
|
if tag[u'start tag'] == u'{br}':
|
||||||
continue
|
continue
|
||||||
if tag[u'start html'] in text:
|
if tag[u'start tag'] in raw_text and not \
|
||||||
missing_raw_tags.append((tag[u'start tag'], text.find(tag[u'start html'])))
|
tag[u'end tag'] in raw_text:
|
||||||
missing_html_tags.append((tag[u'start html'], text.find(tag[u'start html'])))
|
raw_tags.append(
|
||||||
elif tag[u'start tag'] in text:
|
(tag[u'start tag'], raw_text.find(tag[u'start tag'])))
|
||||||
missing_raw_tags.append((tag[u'start tag'], text.find(tag[u'start tag'])))
|
html_tags.append(
|
||||||
missing_html_tags.append((tag[u'start html'], text.find(tag[u'start tag'])))
|
(tag[u'start html'], raw_text.find(tag[u'start tag'])))
|
||||||
missing_raw_tags.sort(key=lambda tag: tag[1])
|
# Sort the lists, so that the tags which were opened first on the first
|
||||||
missing_html_tags.sort(key=lambda tag: tag[1])
|
# slide (the text we are checking) will be opened first on the next
|
||||||
return u''.join(missing_raw_tags), u''.join(missing_html_tags)
|
# slide as well.
|
||||||
|
raw_tags.sort(key=lambda tag: tag[1])
|
||||||
|
html_tags.sort(key=lambda tag: tag[1])
|
||||||
|
# Remove the indexes.
|
||||||
|
raw_tags = [tag[0] for tag in raw_tags]
|
||||||
|
html_tags = [tag[0] for tag in html_tags]
|
||||||
|
return u''.join(raw_tags), u''.join(html_tags)
|
||||||
|
|
||||||
def _binary_chop(self, formatted, previous_html, previous_raw, html_list,
|
def _binary_chop(self, formatted, previous_html, previous_raw, html_list,
|
||||||
raw_list, separator, line_end):
|
raw_list, separator, line_end):
|
||||||
|
Loading…
Reference in New Issue
Block a user