mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
EPUB Output: Remove hyperlinks with no content as they cause rendering artifacts in browser based renderers
This commit is contained in:
parent
5edb60dc1c
commit
923cf3522c
@ -148,6 +148,20 @@ class EPUBOutput(OutputFormatPlugin):
|
||||
if not pre.text and len(pre) == 0:
|
||||
pre.tag = 'div'
|
||||
|
||||
# Remove hyperlinks with no content as they cause rendering
|
||||
# artifacts in browser based renderers
|
||||
for a in body.xpath('//a[@href]'):
|
||||
if a.get('id', None) is None and a.get('name', None) is None \
|
||||
and len(a) == 0 and not a.text:
|
||||
p = a.getparent()
|
||||
idx = p.index(a) -1
|
||||
p.remove(a)
|
||||
if a.tail:
|
||||
if idx <= 0:
|
||||
p.text += a.tail
|
||||
else:
|
||||
p[idx].tail += a.tail
|
||||
|
||||
|
||||
def convert(self, oeb, output_path, input_plugin, opts, log):
|
||||
self.log, self.opts, self.oeb = log, opts, oeb
|
||||
|
Loading…
x
Reference in New Issue
Block a user