diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index ac7e95c4c..711be4227 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -229,13 +229,33 @@ class Renderer(object): pages = self._paginate_slide(lines, line_end) if len(pages) > 1: # Songs and Custom - if item.is_capable(ItemCapabilities.AllowsVirtualSplit): - # Do not forget the line breaks! - slides = text.split(u'[---]') + if item.is_capable(ItemCapabilities.AllowsVirtualSplit) and \ + u'[---]' in text: pages = [] - for slide in slides: - lines = slide.strip(u'\n').split(u'\n') - pages.extend(self._paginate_slide(lines, line_end)) + while True: + html_text = expand_tags(text.split(u'[---]', 1)[0]) + html_text = html_text.strip() + html_text = html_text.replace(u'\n', u'
') + if not self._text_fits_on_slide(html_text): + text = text.replace(u'\n[---]', u'', 1) + else: + if u'[---]' in text: + slides = text.split(u'[---]', 1) + text_to_render = slides[0] + text_to_render = text_to_render.strip() + text_to_render = text_to_render.replace(u'\n', u'
') + text = slides[1] + else: + text_to_render = text + text = u'' + lines = text_to_render.strip(u'\n').split(u'\n') + lines = map(expand_tags, lines) + pages.extend(self._paginate_slide(lines, line_end)) + if not text or u'[---]' not in text: + lines = text.strip(u'\n').split(u'\n') + lines = map(expand_tags, lines) + pages.extend(self._paginate_slide(lines, line_end)) + break new_pages = [] for page in pages: while page.endswith(u'
'): @@ -488,7 +508,7 @@ class Renderer(object): returned, otherwise ``False``. ``text`` - The text to check. It can contain HTML tags. + The text to check. It may contain HTML tags. """ self.web_frame.evaluateJavaScript(u'show_text("%s")' % text.replace(u'\\', u'\\\\').replace(u'\"', u'\\\"'))