View Single Post
Old 06-19-2018, 11:16 AM   #414
Gergely
Member
Gergely understands when you whisper 'The dog barks at midnight.'Gergely understands when you whisper 'The dog barks at midnight.'Gergely understands when you whisper 'The dog barks at midnight.'Gergely understands when you whisper 'The dog barks at midnight.'Gergely understands when you whisper 'The dog barks at midnight.'Gergely understands when you whisper 'The dog barks at midnight.'Gergely understands when you whisper 'The dog barks at midnight.'Gergely understands when you whisper 'The dog barks at midnight.'Gergely understands when you whisper 'The dog barks at midnight.'Gergely understands when you whisper 'The dog barks at midnight.'Gergely understands when you whisper 'The dog barks at midnight.'
 
Posts: 19
Karma: 42210
Join Date: May 2018
Device: Kobo Aura H2O
Valid filename from href?

Still want to highlight text in an epub.

I thought of ignoring html parsing as my replacement is not about html structure. I just want to find a text in the html and replace it with span and /span enclosed. Simple python string replace would do it:

https://www.tutorialspoint.com/pytho...ng_replace.htm

The html file iterator is the following in the testme3 plugin:

# all xhtml/html files
print("\nExercising: bk.text_iter()")
for (id, href) in bk.text_iter():
print(id, href)
lastid = id

I get a href for the html files in the ebook.

with open(href, 'r') as myfile:
data=myfile.read()

leads to error message

FileNotFoundError: [Errno 2] No such file or directory: 'Text/9781118087220cover.xhtml'

How can I create a valid filename from href?
Gergely is offline   Reply With Quote