@@ -41,6 +41,7 @@ def ace_fix_mec(epub: Epub):
41
41
html_tree = ElementTree (etree .fromstring (data ))
42
42
set_lang (html_tree , lang )
43
43
fix_trn_links (html_tree )
44
+ fix_hotspot_links_kf8 (html_tree )
44
45
data = etree .tostring (html_tree , xml_declaration = True , encoding = "utf-8" , pretty_print = True )
45
46
epub .write (page_path , data )
46
47
yield "All content pages fixed and updated"
@@ -127,6 +128,22 @@ def fix_trn_links(html_tree):
127
128
return html_tree
128
129
129
130
131
+ def fix_hotspot_links_kf8 (html_tree ):
132
+ # type: (ElementTree) -> ElementTree
133
+ """Add required title attribute to MagicEpub hotspot link elements"""
134
+ root = html_tree .getroot ()
135
+ namespaces = {
136
+ "xhtml" : "http://www.w3.org/1999/xhtml" ,
137
+ "epub" : "http://www.idpf.org/2007/ops" ,
138
+ }
139
+ hot_spot_divs = root .xpath ('//xhtml:div[@class="hotspot"]' , namespaces = namespaces )
140
+ for div in hot_spot_divs :
141
+ link = div .find (".//xhtml:a" , namespaces = namespaces )
142
+ if link is not None :
143
+ link .set ("title" , "Link area" )
144
+ return html_tree
145
+
146
+
130
147
if __name__ == "__main__" :
131
148
fp = r"../scratch/test1.epub"
132
149
epb = Epub (fp , clone = True )
0 commit comments