From d068d11c76e8b34575a7fd10a2dc56db4863f270 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Tue, 24 May 2011 17:06:38 +0200 Subject: [PATCH 2/4] (started to) fix bug #86896 --- openlp/core/lib/__init__.py | 4 ++ openlp/core/lib/serviceitem.py | 5 +- openlp/plugins/songs/lib/songbeamerimport.py | 52 ++++++++++---------- 3 files changed, 34 insertions(+), 27 deletions(-) diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index 27a34d54d..af42e3957 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -83,6 +83,9 @@ base_html_expands.append({u'desc': u'Italics', u'start tag': u'{it}', base_html_expands.append({u'desc': u'Underline', u'start tag': u'{u}', u'start html': u'', u'end tag': u'{/u}', u'end html': u'', u'protected': True}) +base_html_expands.append({u'desc': u'Break', u'start tag': u'{br}', + u'start html': u'
', u'end tag': u'', u'end html': u'', + u'protected': True}) def translate(context, text, comment=None, encoding=QtCore.QCoreApplication.CodecForTr, n=-1, @@ -244,6 +247,7 @@ def clean_tags(text): Remove Tags from text for display """ text = text.replace(u'
', u'\n') + text = text.replace(u'{br}', u'\n') text = text.replace(u' ', u' ') for tag in DisplayTags.get_html_tags(): text = text.replace(tag[u'start tag'], u'') diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index 95702f229..f7b1ff1c8 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -28,6 +28,7 @@ The :mod:`serviceitem` provides the service item functionality including the type and capability of an item. """ +import cgi import datetime import logging import os @@ -174,10 +175,12 @@ class ServiceItem(object): formatted = self.renderer \ .format_slide(slide[u'raw_slide'], line_break, self) for page in formatted: + page = page.replace(u'
', u'{br}') + html = cgi.escape(page.rstrip().replace(u'
', u'{br}')) self._display_frames.append({ u'title': clean_tags(page), u'text': clean_tags(page.rstrip()), - u'html': expand_tags(page.rstrip()), + u'html': expand_tags(cgi.escape(page.rstrip())), u'verseTag': slide[u'verseTag'] }) elif self.service_item_type == ServiceItemType.Image or \ diff --git a/openlp/plugins/songs/lib/songbeamerimport.py b/openlp/plugins/songs/lib/songbeamerimport.py index 861ec2e99..5a83f54cd 100644 --- a/openlp/plugins/songs/lib/songbeamerimport.py +++ b/openlp/plugins/songs/lib/songbeamerimport.py @@ -68,6 +68,30 @@ class SongBeamerImport(SongImport): Song Beamer file format is text based in the beginning are one or more control tags written """ + HTML_TAG_PAIRS = [ + (re.compile(u''), u'{st}'), + (re.compile(u''), u'{/st}'), + (re.compile(u''), u'{it}'), + (re.compile(u''), u'{/it}'), + (re.compile(u''), u'{u}'), + (re.compile(u''), u'{/u}'), + (re.compile(u'

'), u'{p}'), + (re.compile(u'

'), u'{/p}'), + (re.compile(u''), u'{su}'), + (re.compile(u''), u'{/su}'), + (re.compile(u''), u'{sb}'), + (re.compile(u''), u'{/sb}'), + (re.compile(u''), u'{br}'), + (re.compile(u'<[/]?wordwrap>'), u''), + (re.compile(u'<[/]?strike>'), u''), + (re.compile(u'<[/]?h.*?>'), u''), + (re.compile(u'<[/]?s.*?>'), u''), + (re.compile(u'<[/]?linespacing.*?>'), u''), + (re.compile(u'<[/]?c.*?>'), u''), + (re.compile(u''), u''), + (re.compile(u''), u'') + ] + def __init__(self, manager, **kwargs): """ Initialise the Song Beamer importer. @@ -133,32 +157,8 @@ class SongBeamerImport(SongImport): This can be called to replace SongBeamer's specific (html) tags with OpenLP's specific (html) tags. """ - tag_pairs = [ - (u'', u'{st}'), - (u'', u'{/st}'), - (u'', u'{it}'), - (u'', u'{/it}'), - (u'', u'{u}'), - (u'', u'{/u}'), - (u'

', u'{p}'), - (u'

', u'{/p}'), - (u'', u'{su}'), - (u'', u'{/su}'), - (u'', u'{sb}'), - (u'', u'{/sb}'), - (u'<[/]?br.*?>', u'{st}'), - (u'<[/]?wordwrap>', u''), - (u'<[/]?strike>', u''), - (u'<[/]?h.*?>', u''), - (u'<[/]?s.*?>', u''), - (u'<[/]?linespacing.*?>', u''), - (u'<[/]?c.*?>', u''), - (u'', u''), - (u'', u'') - ] - for pair in tag_pairs: - self.current_verse = re.compile(pair[0]).sub(pair[1], - self.current_verse) + for pair in SongBeamerImport.HTML_TAG_PAIRS: + self.current_verse = pair[0].sub(pair[1], self.current_verse) def parse_tags(self, line): """ From b9bcd98716eee9ff2c741bd1154d6c281ebffac8 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Tue, 24 May 2011 18:51:40 +0200 Subject: [PATCH 3/4] removed not need line --- openlp/core/lib/serviceitem.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index f7b1ff1c8..84379c076 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -176,7 +176,6 @@ class ServiceItem(object): .format_slide(slide[u'raw_slide'], line_break, self) for page in formatted: page = page.replace(u'
', u'{br}') - html = cgi.escape(page.rstrip().replace(u'
', u'{br}')) self._display_frames.append({ u'title': clean_tags(page), u'text': clean_tags(page.rstrip()), From 3a91365e5a18ad819487d7458d02ee28d7598b6d Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 25 May 2011 15:14:59 +0200 Subject: [PATCH 4/4] fixed space Fixes: https://launchpad.net/bugs/786896 --- openlp/core/lib/serviceitem.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index 3ffe74ae7..6e3d0aa97 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -187,7 +187,7 @@ class ServiceItem(object): self.service_item_type == ServiceItemType.Command: pass else: - log.error(u'Invalid value renderer :%s' % self.service_item_type) + log.error(u'Invalid value renderer: %s' % self.service_item_type) self.title = clean_tags(self.title) # The footer should never be None, but to be compatible with a few # nightly builds between 1.9.4 and 1.9.5, we have to correct this to