Port use of BS in Kindle and Kobo drivers

This commit is contained in:
Kovid Goyal 2019-03-24 14:13:06 +05:30
parent 2fc337d779
commit 5e097e3ac7
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 14 additions and 18 deletions

View File

@ -213,20 +213,17 @@ class KINDLE(USBMS):
divTag['class'] = 'user_annotations'
# Add the last-read location
spanTag = ka_soup.new_tag('span')
spanTag['style'] = 'font-weight:bold'
if bookmark.book_format == 'pdf':
spanTag.insert(0,BeautifulSoup(
_("%(time)s<br />Last page read: %(loc)d (%(pr)d%%)") % dict(
markup = _("%(time)s<br />Last page read: %(loc)d (%(pr)d%%)") % dict(
time=strftime(u'%x', timestamp.timetuple()),
loc=last_read_location,
pr=percent_read)))
pr=percent_read)
else:
spanTag.insert(0,BeautifulSoup(
_("%(time)s<br />Last page read: Location %(loc)d (%(pr)d%%)") % dict(
markup = _("%(time)s<br />Last page read: Location %(loc)d (%(pr)d%%)") % dict(
time=strftime(u'%x', timestamp.timetuple()),
loc=last_read_location,
pr=percent_read)))
pr=percent_read)
spanTag = BeautifulSoup('<span style="font-weight:bold">' + markup + '</span>').find('span')
divTag.insert(dtc, spanTag)
dtc += 1
@ -261,7 +258,8 @@ class KINDLE(USBMS):
typ=user_notes[location]['type']))
for annotation in annotations:
divTag.insert(dtc, BeautifulSoup(annotation))
annot = BeautifulSoup('<span>' + annotations + '</span>').find('span')
divTag.insert(dtc, annot)
dtc += 1
ka_soup.insert(0,divTag)

View File

@ -1222,20 +1222,17 @@ class KOBO(USBMS):
divTag['class'] = 'user_annotations'
# Add the last-read location
spanTag = ka_soup.new_tag('span')
spanTag['style'] = 'font-weight:normal'
if bookmark.book_format == 'epub':
spanTag.insert(0,BeautifulSoup(
_("<hr /><b>Book last read:</b> %(time)s<br /><b>Percentage read:</b> %(pr)d%%<hr />") % dict(
markup = _("<hr /><b>Book last read:</b> %(time)s<br /><b>Percentage read:</b> %(pr)d%%<hr />") % dict(
time=last_read,
# loc=last_read_location,
pr=percent_read)))
pr=percent_read)
else:
spanTag.insert(0,BeautifulSoup(
_("<hr /><b>Book last read:</b> %(time)s<br /><b>Percentage read:</b> %(pr)d%%<hr />") % dict(
markup = _("<hr /><b>Book last read:</b> %(time)s<br /><b>Percentage read:</b> %(pr)d%%<hr />") % dict(
time=last_read,
# loc=last_read_location,
pr=percent_read)))
pr=percent_read)
spanTag = BeautifulSoup('<span style="font-weight:normal">' + markup + '</span>').find('span')
divTag.insert(dtc, spanTag)
dtc += 1
@ -1294,7 +1291,8 @@ class KOBO(USBMS):
annotation=user_notes[location]['annotation']))
for annotation in annotations:
divTag.insert(dtc, BeautifulSoup(annotation))
annot = BeautifulSoup('<span>' + annotations + '</span>').find('span')
divTag.insert(dtc, annot)
dtc += 1
ka_soup.insert(0,divTag)