Merge branch 'issue-434-fix-wordproject-import' into 'master'

Fix #434 by handling links with titles

Closes #434

See merge request openlp/openlp!235
This commit is contained in:
Tim Bentley 2020-09-23 06:42:20 +00:00
commit 3c224a9874
2 changed files with 9 additions and 4 deletions

View File

@ -83,12 +83,17 @@ class WordProjectBible(BibleImport):
log.debug(li_book)
if self.stop_import_flag:
break
# Sometimes the structure is "[1] <a>Genesis</a>", and sometimes it's "<a>[1] Genesis</a>"
if isinstance(li_book.contents[0], NavigableString) and str(li_book.contents[0]).strip():
# Sometimes the structure is "[1] <a>Genesis</a>", and sometimes it's "<a>[1] Genesis</a>"
book_string = str(li_book.contents[0])
book_name = str(li_book.a.contents[0])
elif li_book.a:
elif li_book.a and ']' in li_book.a.contents[0]:
# Sometimes there is a [1] in the link text
book_string, book_name = str(li_book.a.contents[0]).split(' ', 1)
elif li_book.a and 'title' in li_book.a.attrs:
# And sometimes there's a title on the a with the number in it
book_string = li_book.a['title'].split(' ')[0]
book_name = li_book.a.contents[0].strip()
book_link = li_book.a['href']
book_id = int(BOOK_NUMBER_PATTERN.search(book_string).group(1))
book_name = book_name.strip()

View File

@ -107,11 +107,11 @@
<div class="ym-g50 ym-gl">
<h3>Old Testament</h3>
<ul id="maintab" class="shadetabs">
<li><a href="01/1.htm">[1] Genesis <i class="icon-headphones pull-right"></i></a></li>
<li>[1] <a href="01/1.htm">Genesis <i class="icon-headphones pull-right"></i></a></li>
<li><a href="02/1.htm">[2] Exodus <i class="icon-headphones pull-right"></i></a></li>
<li><a href="03/1.htm">[3] Leviticus <i class="icon-headphones pull-right"></i></a></li>
<li><a href="04/1.htm">[4] Numbers <i class="icon-headphones pull-right"></i></a></li>
<li><a href="05/1.htm">[5] Deuteronomy <i class="icon-headphones pull-right"></i></a></li>
<li><a href="05/1.htm" title="[5] Deuteronomy">Deuteronomy <i class="icon-headphones pull-right"></i></a></li>
<li><a href="06/1.htm">[6] Joshua <i class="icon-headphones pull-right"></i></a></li>
<li><a href="07/1.htm">[7] Judges <i class="icon-headphones pull-right"></i></a></li>
<li><a href="08/1.htm">[8] Ruth <i class="icon-headphones pull-right"></i></a></li>