final fixes and clean ups

This commit is contained in:
Andreas Preikschat 2011-09-18 12:26:47 +02:00
parent 4c869fa1f5
commit 3c3339f114

View File

@ -440,21 +440,41 @@ class Renderer(object):
log.debug(u'_paginate_slide_words - End')
return formatted
def _get_start_tags(self, text):
missing_raw_tags = []
missing_html_tags = []
def _get_start_tags(self, raw_text):
"""
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():
if tag[u'start html'] == u'<br>':
if tag[u'start tag'] == u'{br}':
continue
if tag[u'start html'] in text:
missing_raw_tags.append((tag[u'start tag'], text.find(tag[u'start html'])))
missing_html_tags.append((tag[u'start html'], text.find(tag[u'start html'])))
elif tag[u'start tag'] in text:
missing_raw_tags.append((tag[u'start tag'], text.find(tag[u'start tag'])))
missing_html_tags.append((tag[u'start html'], text.find(tag[u'start tag'])))
missing_raw_tags.sort(key=lambda tag: tag[1])
missing_html_tags.sort(key=lambda tag: tag[1])
return u''.join(missing_raw_tags), u''.join(missing_html_tags)
if tag[u'start tag'] in raw_text and not \
tag[u'end tag'] in raw_text:
raw_tags.append(
(tag[u'start tag'], raw_text.find(tag[u'start tag'])))
html_tags.append(
(tag[u'start html'], raw_text.find(tag[u'start tag'])))
# Sort the lists, so that the tags which were opened first on the first
# slide (the text we are checking) will be opened first on the next
# 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,
raw_list, separator, line_end):