Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Sigil

Notices

Reply
 
Thread Tools Search this Thread
Old 05-18-2012, 07:59 PM   #1
bfollowell
Fanatic
bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.
 
Posts: 511
Karma: 1152752
Join Date: Aug 2010
Location: Evansville, IN, USA
Device: Amazon Kindle 3 Wi-Fi & B&N Nook Tablet & B&N Nook HD+
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.
bfollowell is offline   Reply With Quote
Old 05-18-2012, 11:15 PM   #2
theducks
Grand Sorcerer
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 14,651
Karma: 5629001
Join Date: Aug 2009
Location: (The original) Silicon Valley, USA
Device: Galaxy Tab 2, Astak Pocket Pro, K4NT
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>
theducks is online now   Reply With Quote
 
Enthusiast
Old 05-19-2012, 12:01 AM   #3
bfollowell
Fanatic
bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.
 
Posts: 511
Karma: 1152752
Join Date: Aug 2010
Location: Evansville, IN, USA
Device: Amazon Kindle 3 Wi-Fi & B&N Nook Tablet & B&N Nook HD+
Quote:
Originally Posted by theducks View Post
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>
Well, I understand that much but it's just text when I'm searching & replacing. Again, there were only 33 matches for my search. Sigil even said only 33 replacements were made. Why then, do I have 477 instances?

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
bfollowell is offline   Reply With Quote
Old 05-19-2012, 12:09 AM   #4
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 9,062
Karma: 40855212
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Bad things happen when you allow tags to be automagically closed for you.
DiapDealer is offline   Reply With Quote
Old 05-19-2012, 12:25 AM   #5
bfollowell
Fanatic
bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.
 
Posts: 511
Karma: 1152752
Join Date: Aug 2010
Location: Evansville, IN, USA
Device: Amazon Kindle 3 Wi-Fi & B&N Nook Tablet & B&N Nook HD+
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
bfollowell is offline   Reply With Quote
Old 05-19-2012, 12:44 AM   #6
bfollowell
Fanatic
bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.
 
Posts: 511
Karma: 1152752
Join Date: Aug 2010
Location: Evansville, IN, USA
Device: Amazon Kindle 3 Wi-Fi & B&N Nook Tablet & B&N Nook HD+
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
bfollowell is offline   Reply With Quote
Old 05-19-2012, 12:56 AM   #7
Ahmad Samir
Zealot
Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!
 
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>
Then Tidy will go way overboard because of the unclosed <span> tag, and it will insert a <span> to every single paragraph after the first one, until the end of the html/xhtml file.

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.
Ahmad Samir is offline   Reply With Quote
Old 05-19-2012, 01:18 AM   #8
cybmole
Wizard
cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.
 
Posts: 2,793
Karma: 1089170
Join Date: Sep 2010
Device: Kobo aura HD, Kobo Arc, Kindle Fire HDX 8.9 , Kindle for PC
Quote:
Originally Posted by bfollowell View Post
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
that is easy
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!
cybmole is offline   Reply With Quote
Old 05-19-2012, 01:33 AM   #9
bfollowell
Fanatic
bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.
 
Posts: 511
Karma: 1152752
Join Date: Aug 2010
Location: Evansville, IN, USA
Device: Amazon Kindle 3 Wi-Fi & B&N Nook Tablet & B&N Nook HD+
Quote:
Originally Posted by cybmole View Post
that is easy
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!
I thought the same thing but was just trying to follow along with the techniques the publisher had seemed to be using in other areas of the epub.

Still, this little exercise taught me quite a bit.

Thanks for all of your help and advice everyone.

- Byron
bfollowell is offline   Reply With Quote
Old 05-19-2012, 02:36 AM   #10
cybmole
Wizard
cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.
 
Posts: 2,793
Karma: 1089170
Join Date: Sep 2010
Device: Kobo aura HD, Kobo Arc, Kindle Fire HDX 8.9 , Kindle for PC
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
cybmole is offline   Reply With Quote
Old 05-19-2012, 07:41 AM   #11
theducks
Grand Sorcerer
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 14,651
Karma: 5629001
Join Date: Aug 2009
Location: (The original) Silicon Valley, USA
Device: Galaxy Tab 2, Astak Pocket Pro, K4NT
Quote:
Originally Posted by cybmole View Post
that is easy
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!
You DO NOT enclose additional styles in additional quotes (see many styles with SGC-# as examples)

Code:
<p class="para italic">
is the proper way to write it.

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
(if it was used only in these cases)
theducks is online now   Reply With Quote
Old 05-19-2012, 08:23 AM   #12
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 9,062
Karma: 40855212
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by theducks View Post
Maybe all you needed to do was add/adjust the c2 class in the style sheet.

Code:
font-stye: italic
(if it was used only in these cases)
That's what I'd do. I never understood having spans that encompassed entire paragraphs anyway. Just modify the paragraph's css class (or create a new one) to accommodate what the span was trying to accomplish (or assign two classes to the paragraph like has been previously mentioned <p class="class1 class2">).

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>
EDIT: Just note that if you have any hopes of building a MOBI (at least a non-KF8 MOBI) from the very same ePub using kindlegen -- then the <p class="class1 class2"> approach should be avoided like the plague.

Last edited by DiapDealer; 05-19-2012 at 08:28 AM.
DiapDealer is offline   Reply With Quote
Old 05-19-2012, 11:04 AM   #13
theducks
Grand Sorcerer
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 14,651
Karma: 5629001
Join Date: Aug 2009
Location: (The original) Silicon Valley, USA
Device: Galaxy Tab 2, Astak Pocket Pro, K4NT
Quote:
Originally Posted by DiapDealer View Post

EDIT: Just note that if you have any hopes of building a MOBI (at least a non-KF8 MOBI) from the very same ePub using kindlegen -- then the <p class="class1 class2"> approach should be avoided like the plague.
Calibre wont handle that in conversion? (You can tell I don't do many Mobi )
theducks is online now   Reply With Quote
Old 05-19-2012, 11:53 AM   #14
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 9,062
Karma: 40855212
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by theducks View Post
Calibre wont handle that in conversion? (You can tell I don't do many Mobi )
Calibre deals with multiple css classes being assigned to one element pretty well when converting ePub to MOBI. It's kindlegen that can't (or couldn't) handle it.
DiapDealer is offline   Reply With Quote
Old 05-19-2012, 01:14 PM   #15
theducks
Grand Sorcerer
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 14,651
Karma: 5629001
Join Date: Aug 2009
Location: (The original) Silicon Valley, USA
Device: Galaxy Tab 2, Astak Pocket Pro, K4NT
Quote:
Originally Posted by DiapDealer View Post
Calibre deals with multiple css classes being assigned to one element pretty well when converting ePub to MOBI. It's kindlegen that can't (or couldn't) handle it.
Wheew!
theducks is online now   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

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


All times are GMT -4. The time now is 11:42 PM.


MobileRead.com is a privately owned, operated and funded community.