openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #08424
[Merge] lp:~googol-hush/openlp/render into lp:openlp
Andreas Preikschat has proposed merging lp:~googol-hush/openlp/render into lp:openlp.
Requested reviews:
OpenLP Core (openlp-core)
For more details, see:
https://code.launchpad.net/~googol-hush/openlp/render/+merge/59467
Hello,
- fixed wrong use of strip()
- fixed soft break not working, when used within a line.
- removed redundant code
--
https://code.launchpad.net/~googol-hush/openlp/render/+merge/59467
Your team OpenLP Core is requested to review the proposed merge of lp:~googol-hush/openlp/render into lp:openlp.
=== modified file 'openlp/core/lib/renderer.py'
--- openlp/core/lib/renderer.py 2011-04-28 06:44:48 +0000
+++ openlp/core/lib/renderer.py 2011-04-29 08:30:56 +0000
@@ -25,6 +25,7 @@
###############################################################################
import logging
+import re
from PyQt4 import QtCore, QtWebKit
@@ -222,13 +223,13 @@
# Songs and Custom
if item.is_capable(ItemCapabilities.AllowsVirtualSplit):
# Do not forget the line breaks !
- slides = text.split(u'\n[---]\n')
+ slides = text.split(u'[---]')
pages = []
for slide in slides:
- lines = self._lines(slide)
+ lines = self._lines(slide.strip(u'\n'))
new_pages = self._paginate_slide(lines, line_break,
self.force_page)
- pages.extend([page for page in new_pages])
+ pages.extend(new_pages)
# Bibles
elif item.is_capable(ItemCapabilities.AllowsWordSplit):
pages = self._paginate_slide_words(text, line_break)
@@ -341,12 +342,12 @@
if force_page and line_count > 0:
Receiver.send_message(u'theme_line_count', line_count)
line_count = -1
- html_text = html_text.rstrip(u'<br>')
+ html_text = re.compile(r'<br>.*$').sub(u'', html_text)
formatted.append(html_text)
html_text = u''
styled_text = styled_line
html_text += line + line_end
- html_text = html_text.rstrip(u'<br>')
+ html_text = re.compile(r'<br>.*$').sub(u'', html_text)
formatted.append(html_text)
log.debug(u'_paginate_slide - End')
return formatted
@@ -385,7 +386,8 @@
self.web.setHtml(html)
if self.web_frame.contentsSize().height() <= \
self.page_height:
- previous_raw = previous_raw.rstrip(u'<br>')
+ previous_raw = re.compile(
+ r'<br>.*$').sub(u'', previous_raw)
formatted.append(previous_raw)
previous_html = u''
previous_raw = u''
@@ -408,7 +410,8 @@
# Text too long so go to next page
if self.web_frame.contentsSize().height() > \
self.page_height:
- previous_raw = previous_raw.rstrip(u'<br>')
+ previous_raw = re.compile(
+ r'<br>.*$').sub(u'', previous_raw)
formatted.append(previous_raw)
previous_html = u''
previous_raw = u''
@@ -419,7 +422,7 @@
else:
previous_html += styled_line + line_end
previous_raw += line + line_end
- previous_raw = previous_raw.rstrip(u'<br>')
+ previous_raw = re.compile(r'<br>.*$').sub(u'', previous_raw)
formatted.append(previous_raw)
log.debug(u'_paginate_slide_words - End')
return formatted
@@ -429,13 +432,7 @@
Split the slide up by physical line
"""
# this parse we do not want to use this so remove it
- verses_text = text.split(u'\n')
- text = []
- for verse in verses_text:
- lines = verse.split(u'\n')
- text.extend([line for line in lines])
-
- return text
+ return text.split(u'\n')
def _words_split(self, line):
"""
@@ -443,12 +440,8 @@
"""
# this parse we are to be wordy
line = line.replace(u'\n', u' ')
- verses_text = line.split(u' ')
- text = []
- for verse in verses_text:
- lines = verse.split(u' ')
- text.extend([line + u' ' for line in lines])
- return text
+ words = line.split(u' ')
+ return [word + u' ' for word in words]
def _lines_split(self, text):
"""
@@ -457,9 +450,4 @@
# this parse we do not want to use this so remove it
text = text.replace(u'\n[---]', u'')
lines = text.split(u'\n')
- real_lines = []
- for line in lines:
- line = line.replace(u'[---]', u'')
- sub_lines = line.split(u'\n')
- real_lines.extend([sub_line for sub_line in sub_lines])
- return real_lines
+ return [line.replace(u'[---]', u'') for line in lines]
Follow ups