openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #09161
[Merge] lp:~googol-hush/openlp/bug-786896 into lp:openlp
Andreas Preikschat has proposed merging lp:~googol-hush/openlp/bug-786896 into lp:openlp.
Requested reviews:
OpenLP Core (openlp-core)
Related bugs:
Bug #786896 in OpenLP: "HTML text in slide text needs to be escaped"
https://bugs.launchpad.net/openlp/+bug/786896
For more details, see:
https://code.launchpad.net/~googol-hush/openlp/bug-786896/+merge/62294
Hello,
- Fixed bug #786896
- New display tag {br}
- Better regex usage in the SongBeamer import
A service file to test this: http://ubuntuone.com/p/vW7/
http://wiki.openlp.org/Version_2_Milestones#Important_notes_3
--
https://code.launchpad.net/~googol-hush/openlp/bug-786896/+merge/62294
Your team OpenLP Core is requested to review the proposed merge of lp:~googol-hush/openlp/bug-786896 into lp:openlp.
=== modified file 'openlp/core/lib/__init__.py'
--- openlp/core/lib/__init__.py 2011-05-24 20:47:05 +0000
+++ openlp/core/lib/__init__.py 2011-05-25 13:17:31 +0000
@@ -84,6 +84,9 @@
base_html_expands.append({u'desc': u'Underline', u'start tag': u'{u}',
u'start html': u'<span style="text-decoration: underline;">',
u'end tag': u'{/u}', u'end html': u'</span>', u'protected': True})
+base_html_expands.append({u'desc': u'Break', u'start tag': u'{br}',
+ u'start html': u'<br>', u'end tag': u'', u'end html': u'',
+ u'protected': True})
def translate(context, text, comment=None,
encoding=QtCore.QCoreApplication.CodecForTr, n=-1,
@@ -245,6 +248,7 @@
Remove Tags from text for display
"""
text = text.replace(u'<br>', 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'')
=== modified file 'openlp/core/lib/serviceitem.py'
--- openlp/core/lib/serviceitem.py 2011-05-24 20:47:05 +0000
+++ openlp/core/lib/serviceitem.py 2011-05-25 13:17:31 +0000
@@ -29,6 +29,7 @@
type and capability of an item.
"""
+import cgi
import datetime
import logging
import os
@@ -175,17 +176,18 @@
formatted = self.renderer \
.format_slide(slide[u'raw_slide'], line_break, self)
for page in formatted:
+ page = page.replace(u'<br>', 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 \
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
=== modified file 'openlp/plugins/songs/lib/songbeamerimport.py'
--- openlp/plugins/songs/lib/songbeamerimport.py 2011-05-24 20:47:05 +0000
+++ openlp/plugins/songs/lib/songbeamerimport.py 2011-05-25 13:17:31 +0000
@@ -69,6 +69,30 @@
Song Beamer file format is text based
in the beginning are one or more control tags written
"""
+ HTML_TAG_PAIRS = [
+ (re.compile(u'<b>'), u'{st}'),
+ (re.compile(u'</b>'), u'{/st}'),
+ (re.compile(u'<i>'), u'{it}'),
+ (re.compile(u'</i>'), u'{/it}'),
+ (re.compile(u'<u>'), u'{u}'),
+ (re.compile(u'</u>'), u'{/u}'),
+ (re.compile(u'<p>'), u'{p}'),
+ (re.compile(u'</p>'), u'{/p}'),
+ (re.compile(u'<super>'), u'{su}'),
+ (re.compile(u'</super>'), u'{/su}'),
+ (re.compile(u'<sub>'), u'{sb}'),
+ (re.compile(u'</sub>'), u'{/sb}'),
+ (re.compile(u'<br.*?>'), 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'<align.*?>'), u''),
+ (re.compile(u'<valign.*?>'), u'')
+ ]
+
def __init__(self, manager, **kwargs):
"""
Initialise the Song Beamer importer.
@@ -134,32 +158,8 @@
This can be called to replace SongBeamer's specific (html) tags with
OpenLP's specific (html) tags.
"""
- tag_pairs = [
- (u'<b>', u'{st}'),
- (u'</b>', u'{/st}'),
- (u'<i>', u'{it}'),
- (u'</i>', u'{/it}'),
- (u'<u>', u'{u}'),
- (u'</u>', u'{/u}'),
- (u'<p>', u'{p}'),
- (u'</p>', u'{/p}'),
- (u'<super>', u'{su}'),
- (u'</super>', u'{/su}'),
- (u'<sub>', u'{sb}'),
- (u'</sub>', 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'<align.*?>', u''),
- (u'<valign.*?>', 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):
"""
Follow ups