Tomas Groth has proposed merging lp:~tomasgroth/openlp/24bugfix-backport5 into 
lp:openlp/2.4.

Requested reviews:
  OpenLP Core (openlp-core)
Related bugs:
  Bug #1618489 in OpenLP: "Improper characters in Mediashout import cause 
traceback"
  https://bugs.launchpad.net/openlp/+bug/1618489

For more details, see:
https://code.launchpad.net/~tomasgroth/openlp/24bugfix-backport5/+merge/306677

Fixes getting bible texts from CrossWalk
Fix to handling of form feed char and vertical tab char.
-- 
Your team OpenLP Core is requested to review the proposed merge of 
lp:~tomasgroth/openlp/24bugfix-backport5 into lp:openlp/2.4.
=== modified file 'openlp/plugins/bibles/lib/http.py'
--- openlp/plugins/bibles/lib/http.py	2016-07-27 19:27:14 +0000
+++ openlp/plugins/bibles/lib/http.py	2016-09-23 22:26:31 +0000
@@ -480,7 +480,7 @@
         for verse in verses_div:
             self.application.process_events()
             verse_number = int(verse.find('strong').contents[0])
-            verse_span = verse.find('span')
+            verse_span = verse.find('span', class_='verse-%d' % verse_number)
             tags_to_remove = verse_span.find_all(['a', 'sup'])
             for tag in tags_to_remove:
                 tag.decompose()

=== modified file 'openlp/plugins/songs/lib/importers/mediashout.py'
--- openlp/plugins/songs/lib/importers/mediashout.py	2016-06-16 20:58:11 +0000
+++ openlp/plugins/songs/lib/importers/mediashout.py	2016-09-23 22:26:31 +0000
@@ -93,7 +93,7 @@
             self.song_book_name = song.SongID
         for verse in verses:
             tag = VERSE_TAGS[verse.Type] + str(verse.Number) if verse.Type < len(VERSE_TAGS) else 'O'
-            self.add_verse(verse.Text, tag)
+            self.add_verse(self.tidy_text(verse.Text), tag)
         for order in verse_order:
             if order.Type < len(VERSE_TAGS):
                 self.verse_order_list.append(VERSE_TAGS[order.Type] + str(order.Number))

=== modified file 'openlp/plugins/songs/lib/importers/songimport.py'
--- openlp/plugins/songs/lib/importers/songimport.py	2016-04-21 19:49:22 +0000
+++ openlp/plugins/songs/lib/importers/songimport.py	2016-09-23 22:26:31 +0000
@@ -140,10 +140,13 @@
         text = text.replace('\u2026', '...')
         text = text.replace('\u2013', '-')
         text = text.replace('\u2014', '-')
+        # Replace vertical tab with 2 linebreaks
+        text = text.replace('\v', '\n\n')
+        # Replace form feed (page break) with 2 linebreaks
+        text = text.replace('\f', '\n\n')
         # Remove surplus blank lines, spaces, trailing/leading spaces
-        text = re.sub(r'[ \t\v]+', ' ', text)
+        text = re.sub(r'[ \t]+', ' ', text)
         text = re.sub(r' ?(\r\n?|\n) ?', '\n', text)
-        text = re.sub(r' ?(\n{5}|\f)+ ?', '\f', text)
         return text
 
     def process_song_text(self, text):

_______________________________________________
Mailing list: https://launchpad.net/~openlp-core
Post to     : openlp-core@lists.launchpad.net
Unsubscribe : https://launchpad.net/~openlp-core
More help   : https://help.launchpad.net/ListHelp

Reply via email to