View Single Post
Old 01-09-2022, 12:18 PM   #3
Turtle91
A Hairy Wizard
Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.
 
Turtle91's Avatar
 
Posts: 3,355
Karma: 20171571
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 15/11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
Tag mechanic certainly works!

I do these kinds of changes constantly so I just use a regex find/replace:

Code:
find: <span style="font-weight: bold;">(.*?)</span>
replace: <b>\1</b>
or
replace: <strong>\1</strong>

find: <span style="font-style: italic;">(.*?)</span>
replace: <i>\1</i>
or
replace: <em>\1</em>
Unfortunately it's rare to see two ebooks that use the same style (spaces and ; are different) so I just highlight the <span ....>...</span> and copy that down to the find field, then I replace the text between the span tags with "(.*?)".

You could even make the regex more robust like:
<span style="\s*font-style:\s*italic\s*;*\s*">(.*?)</span>
<span style="\s*font-weight:\s*bold\s*;*\s*">(.*?)</span>

and save it as a saved search (group). That fixes all of them with a single mouse click.

Beware: this process assumes that the ebook spans are simplistic. I have seen some books that throw spans around EVERYTHING and this regex would not correctly select the corresponding </span>. In that case it's probably easier to use tag mechanic.

Code example:
Code:
barf:
<p class="para"><span><span class="calibre9"><span><span class="calibre1">
Hello,</span></span><span><span class="italic">buddy!
</span></span><span><span class="calibre1">How are you?
</span></span></span></span></p>

clean:
<p>Hello, <em>buddy!</em> How are you?</p>
Turtle91 is offline   Reply With Quote