forked from LiveCarta/BookConverter
epub converter: add internal links processing4
This commit is contained in:
@@ -245,15 +245,15 @@ class EpubPostprocessor:
|
||||
new_anchor_already_created = soup.find_all('span',
|
||||
attrs={'class': 'link-anchor',
|
||||
'id': anchor_tag.attrs['id']})
|
||||
if not new_anchor_already_created:
|
||||
if anchor_tag.attrs['id'] not in self.internal_anchors:
|
||||
new_anchor_span = soup.new_tag("span")
|
||||
new_anchor_span.attrs['id'] = anchor_tag.attrs['id']
|
||||
new_anchor_span.attrs['class'] = 'link-anchor'
|
||||
anchor_tag.insert(0, new_anchor_span)
|
||||
new_anchor_span.string = "\xa0"
|
||||
anchor_tag.insert_before(new_anchor_span)
|
||||
self.internal_anchors.add(anchor_tag.attrs['id'])
|
||||
del anchor_tag.attrs['id']
|
||||
self.internal_anchors.add(new_anchor_span)
|
||||
|
||||
del internal_link_tag.attrs['href']
|
||||
del internal_link_tag.attrs['href']
|
||||
|
||||
else:
|
||||
internal_link_tag.attrs['converter-mark'] = 'bad-link'
|
||||
|
||||
@@ -53,6 +53,7 @@ def update_src_links_in_images(body_tag: Tag,
|
||||
new_folder = save_image_locally(path_to_img_from_root, img_content, 'book_id')
|
||||
|
||||
img.attrs['src'] = str(new_folder)
|
||||
img.attrs['style'] = 'align: center;'
|
||||
|
||||
return path2aws_path
|
||||
|
||||
|
||||
Reference in New Issue
Block a user