05-18-2012, 07:59 PM | #1 |
Fanatic
Posts: 541
Karma: 1152752
Join Date: Aug 2010
Location: Evansville, IN, USA
Device: Samsung Galaxy Tab 4 Nook & Samsung Galaxy Tab S 10.5
|
Find/Replace bug?
OK, I have a retail epub that I'm trying to cleanup and Sigil is messing something up and I can't figure out why or how. I am creating some new classes and trying to bulk find replace. I am wanting to replace:
<p class="para c2"> with: <p class="para"><span class="italic"> OK, first of all, I search for <p class="para"><span class="italic"> just to make certain none exist anywhere. Zero instances are found. Next I search for <p class="para c2"> and find that there are 33 instances. Next I enter <p class="para"><span class="italic"> in the replace field and click on Replace All. It says there were 33 replacements made. Now, there were only 33 instances of my find clause found, right, so how could there be more than 33 instances of my new clause when I search for it to see what all was changed? I don't know but when I go back and search for <p class="para"><span class="italic">, I see that there are now 477 instances rather than the expected 33. What the heck?! How is this possible? Anyone ever seen this sort of behavior or have any ideas? I'm currently using v.0.5.3 Thanks. - Byron Followell Last edited by bfollowell; 05-18-2012 at 08:19 PM. |
05-18-2012, 11:15 PM | #2 |
Well trained by Cats
Posts: 29,798
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
para and c2 are 2 different styles to start with(they cascade).
Next you did not close the Span in a known place Code:
<p class="para"><span class="italic">Stuff</span></p>
|
05-19-2012, 12:01 AM | #3 | |
Fanatic
Posts: 541
Karma: 1152752
Join Date: Aug 2010
Location: Evansville, IN, USA
Device: Samsung Galaxy Tab 4 Nook & Samsung Galaxy Tab S 10.5
|
Quote:
As far as not ending the span in a known location, that isn't really an issue. The span ends on each paragraph, like I expected and wanted it to. None of what you pointed out explains to me why Sigil made 33 replacements but I then search and find 477 results. It makes no sense to me. - Byron |
|
05-19-2012, 12:09 AM | #4 |
Grand Sorcerer
Posts: 27,547
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Bad things happen when you allow tags to be automagically closed for you.
|
05-19-2012, 12:25 AM | #5 |
Fanatic
Posts: 541
Karma: 1152752
Join Date: Aug 2010
Location: Evansville, IN, USA
Device: Samsung Galaxy Tab 4 Nook & Samsung Galaxy Tab S 10.5
|
I guess I'm finding that out the hard way. Luckily I was editing a copy so I haven't really screwed anything up. I guess I'll go through and fix them manually.
Thanks guys. - Byron |
05-19-2012, 12:44 AM | #6 |
Fanatic
Posts: 541
Karma: 1152752
Join Date: Aug 2010
Location: Evansville, IN, USA
Device: Samsung Galaxy Tab 4 Nook & Samsung Galaxy Tab S 10.5
|
I think what I need then is a regex expression that will let me find:
<p class="para c2">“Ignore whatever characters may be in this paragraph.”</p> and replace it with: <p class="para"><span class="italic">“Ignore whatever characters may be in this paragraph.”</span></p> Any suggestions? I'm OK with extremely basic regex but I get lost when trying to build larger expressions that will look for something specific with some random text in the middle and then allow me to replace the exact portion of random text as is. - Byron |
05-19-2012, 12:56 AM | #7 |
Zealot
Posts: 114
Karma: 5246
Join Date: Jul 2010
Device: none
|
If you have:
Code:
<p class="foo"><span class="bar">some text</p> <p class="foo">some more text</p> For example, Tidying a file with unclosed tags (e.g. a <span>), you'll get something like: line 7 column 16 - Warning: missing </span> before </p> line 9 column 16 - Warning: inserting implicit <span> line 11 column 16 - Warning: inserting implicit <span> so, yeah, be very careful about unclosed tags with Tidy, e.g. when doing a Replace All in Sigil. |
05-19-2012, 01:18 AM | #8 | |
Wizard
Posts: 3,720
Karma: 1759970
Join Date: Sep 2010
Device: none
|
Quote:
find <p class="para c2">(.*)</p> replace <p class="para"><span class="italic">\1</span></p> but having span in the replace is superfluous so replace <p class="para" "italic">\1 </p> is neater PS so in fact why bother - just define class c2 to mean italic & you are done! |
|
05-19-2012, 01:33 AM | #9 | |
Fanatic
Posts: 541
Karma: 1152752
Join Date: Aug 2010
Location: Evansville, IN, USA
Device: Samsung Galaxy Tab 4 Nook & Samsung Galaxy Tab S 10.5
|
Quote:
Still, this little exercise taught me quite a bit. Thanks for all of your help and advice everyone. - Byron |
|
05-19-2012, 02:36 AM | #10 |
Wizard
Posts: 3,720
Karma: 1759970
Join Date: Sep 2010
Device: none
|
the use of (.*) and \1 to preserve everything between tags is a useful trick
but beware of using it between <div and </div> - that seems to go horribly wrong ( in v4.3 old style regex anyway). I have struggled to find a way to fix up books that use thousands of <div> tag pairs, one set per paragraph, and to replace with <p?> tag pairs i.e. find <Div class =..>"every single paragraph"</div> replace with <p> tags instead of <div> tags |
05-19-2012, 07:41 AM | #11 | |
Well trained by Cats
Posts: 29,798
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Quote:
Code:
<p class="para italic"> Pay attention to the order if there are updated elements. Just to be clear: You are removing C2 class and substituting italic class? Maybe all you needed to do was add/adjust the c2 class in the style sheet. Code:
font-stye: italic |
|
05-19-2012, 08:23 AM | #12 | |
Grand Sorcerer
Posts: 27,547
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Quote:
Nothing's worse than working with an epub that is filled entirely with: Code:
<p class="something"><span class="something-else">blah, blah, blah</span></p> <p class="something"><span class="something-else">blah, dee, blah, dee, blah</span></p> <p class="something"><span class="something-else">blah, dee, blah, blah</span></p> <p class="something"><span class="something-else">blah, dee, blah, blah, blah</span></p> Last edited by DiapDealer; 05-19-2012 at 08:28 AM. |
|
05-19-2012, 11:04 AM | #13 |
Well trained by Cats
Posts: 29,798
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Calibre wont handle that in conversion? (You can tell I don't do many Mobi )
|
05-19-2012, 11:53 AM | #14 |
Grand Sorcerer
Posts: 27,547
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
|
05-19-2012, 01:14 PM | #15 |
Well trained by Cats
Posts: 29,798
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Find Replace | unrulyguides | Sigil | 5 | 02-17-2012 08:38 PM |
Find/Replace Won't Find | Rand Brittain | Sigil | 7 | 09-24-2011 04:35 AM |
Find / replace | bremler | Sigil | 6 | 12-17-2010 03:26 PM |
Crashes on find / replace all | mr ploppy | Sigil | 1 | 02-03-2010 12:35 PM |
Using Find/Replace with BD | Otter | Sony Reader | 7 | 02-28-2009 01:49 PM |