Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Editor

Notices

Reply
 
Thread Tools Search this Thread
Old 09-13-2021, 10:09 PM   #1
GregTheGrate
Connoisseur
GregTheGrate began at the beginning.
 
Posts: 56
Karma: 10
Join Date: Jun 2012
Device: Kindle, iPad
Search and replace sometimes doesn't work across all files

I have had this problem for some time where a search arguement (regex) does not operate across all files in the book and one either has to combine all the files, then do the search/replace or do each file individually.

Last time I reported this and provided a book as an example, I was severely rapped over the knuckles.

Is there some way to provide an example of this which would not get me excommunicated?
GregTheGrate is offline   Reply With Quote
Old 09-13-2021, 10:26 PM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,860
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
If you wish to report a bug and attach a sample, follow the procedure at https://calibre-ebook.com/bugs
kovidgoyal is offline   Reply With Quote
Advert
Old 09-14-2021, 12:20 AM   #3
DNSB
Bibliophagist
DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.
 
DNSB's Avatar
 
Posts: 35,467
Karma: 145525534
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Forma, Clara HD, Lenovo M8 FHD, Paperwhite 4, Tolino epos
Quote:
Originally Posted by GregTheGrate View Post
Is there some way to provide an example of this which would not get me excommunicated?
You might want to check the ScrambleEbook plugin to allow you to munge the contents of a ebook before attaching it on MobileRead.
DNSB is online now   Reply With Quote
Old 09-15-2021, 04:18 PM   #4
retiredbiker
Addict
retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.
 
retiredbiker's Avatar
 
Posts: 387
Karma: 1638210
Join Date: May 2013
Location: Ontario, Canada
Device: Kindle KB, Oasis, Pop_Os!, Jutoh, Kobo Forma
I have found that once in a blue moon, a search in the editor set to "all text files" will only do one file at a time. So rare I've never been able to replicate it on purpose. I've assumed it's just some odd book.

OTOH, I do notice that if you run a saved search (usually several at a time) over "all style files", it will not catch everything unless at least one css file is open. So I've just gotten into the habit of making sure one is open if I do a search like that.
retiredbiker is offline   Reply With Quote
Old 09-15-2021, 04:29 PM   #5
theducks
Well trained by Cats
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: 29,809
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Beautify all files first to even things out
I have had this also. Usually after doing a "current file" replace all (and liking the result, then switching to All files)
I chalked it up to invisible code differences.
theducks is offline   Reply With Quote
Advert
Old 09-16-2021, 12:04 AM   #6
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,860
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
If someone can come up with a reproducible way to make all text files or all style files not do what they are supposed to, I am all ears.
kovidgoyal is offline   Reply With Quote
Old 09-16-2021, 02:25 AM   #7
deback
Book E d i t o r
deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.
 
Posts: 432
Karma: 288184
Join Date: May 2015
Device: Laptop
I've found that you do have to hit Beautify before doing a search. Otherwise, searching might not or usually will not find what you're searching for.
deback is offline   Reply With Quote
Old 11-09-2021, 06:36 PM   #8
GregTheGrate
Connoisseur
GregTheGrate began at the beginning.
 
Posts: 56
Karma: 10
Join Date: Jun 2012
Device: Kindle, iPad
I think I am closer to isolating cases where search does not work across all text files. If you use a search argument (using CMD-F) that is across multiple lines of source, it often does not work across all files
e.g
<p class="calibre_4">

<img src="\.\./images/line\.jpg" class="calibre_5"/>

</p>

will not search across all files in the current book I am editing.

If you change this to

<p class="calibre_4">\s+<img src="\.\./images/line\.jpg" class="calibre_5"/>\s+</p>

then the search works across all files
GregTheGrate is offline   Reply With Quote
Old 11-09-2021, 07:15 PM   #9
retiredbiker
Addict
retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.
 
retiredbiker's Avatar
 
Posts: 387
Karma: 1638210
Join Date: May 2013
Location: Ontario, Canada
Device: Kindle KB, Oasis, Pop_Os!, Jutoh, Kobo Forma
Quote:
Originally Posted by GregTheGrate View Post
I think I am closer to isolating cases where search does not work across all text files. If you use a search argument (using CMD-F) that is across multiple lines of source, it often does not work across all files
e.g
<p class="calibre_4">

<img src="\.\./images/line\.jpg" class="calibre_5"/>

</p>

will not search across all files in the current book I am editing.

If you change this to

<p class="calibre_4">\s+<img src="\.\./images/line\.jpg" class="calibre_5"/>\s+</p>

then the search works across all files
Because whatever is between lines may be invisible linefeeds and spaces, and different in different places in the book, I've always used that "\s+" in cases like this - just SOP.
retiredbiker is offline   Reply With Quote
Old 11-09-2021, 07:21 PM   #10
theducks
Well trained by Cats
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: 29,809
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
or use the flower (beautify) before.
YMMV as to the look of beautiful code, but it will be normalized
theducks is offline   Reply With Quote
Old 11-09-2021, 07:24 PM   #11
Karellen
Wizard
Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.
 
Karellen's Avatar
 
Posts: 1,103
Karma: 4911876
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
Yes, I have found that you need to Beautify the book first to ensure all search results are captured.

I have also found that those that are missed are due to some instances using the No-Break space instead of a standard Space. So I also run a regex to remove those. Usually they are an additional space that is not needed, so I clear them out. It really had me pulling my hair out in my early editing days.

I have also found that when I untick "Wrap" it works as expected on a single file in the Editor, but when using All Files, the unticked Wrap setting is ignored and it wraps around to the start of the book and replaces unwanted instances and I end up with, as an example, <em><em>some word</em></em> which means an additional S&R to clear that out.

Last edited by Karellen; 11-10-2021 at 12:03 AM. Reason: edit to correct misinterpretation
Karellen is offline   Reply With Quote
Old 11-09-2021, 07:26 PM   #12
GregTheGrate
Connoisseur
GregTheGrate began at the beginning.
 
Posts: 56
Karma: 10
Join Date: Jun 2012
Device: Kindle, iPad
Quote:
Originally Posted by retiredbiker View Post
Because whatever is between lines may be invisible linefeeds and spaces, and different in different places in the book, I've always used that "\s+" in cases like this - just SOP.
I agree with you, however CMD-F transfers all characters, visible and invisible to the search argument and if I manually move to the next file, a match is found, so I don't think the original question is yet addressed
GregTheGrate is offline   Reply With Quote
Old 11-09-2021, 11:36 PM   #13
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,907
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
Quote:
Originally Posted by Karellen View Post
Yes, I have found that you need to Beautify the book first to ensure all search results are captured.

I have also found that those that are missed are due to some instances using the No-Break space instead of a standard Space. So I also run a regex to remove those. Usually they are an additional space that is not needed, so I clear them out. It really had me pulling my hair out in my early editing days.

I have also found that "Wrap" works as expected on a single file in the Editor, but when using All Files, the Wrap is ignored and it wraps around to the start of the book and replaces unwanted instances and I end up with, as an example, <em><em>some word</em></em> which means an additional S&R to clear that out.
That sounds like wrapping is working to me. It hits the end of the current context, and goes to the beginning and continues from there. For "Current file" the file is the context. When it gets to the end of the file, it goes back to the beginning of the file and process up to the current position. For "All text files", when it hits the end of the current file, it goes to the next file, and then the next file. It eventually hits the end of all the files and starts at the first file and continues on from there until it hits the starting point. And that means it handles the start of the current file last.

If it is changing "unwanted" instances, then either you have the search wrong, or the search scope wrong. You do run the risk of wrapping and repeating change already made if the changed value matches the search. In your case, if your search was "(some word)" and the change was "<em>\1</em>", then if you didn't stop when you reached the first change, it would match again and you would get a result like you have.
davidfor is offline   Reply With Quote
Old 11-10-2021, 12:02 AM   #14
Karellen
Wizard
Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.
 
Karellen's Avatar
 
Posts: 1,103
Karma: 4911876
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
Quote:
Originally Posted by davidfor View Post
That sounds like wrapping is working to me.
Ahh, I was careless with my proof reading. Let me fix my post so it reads what I intended.

What I meant to say is:

I have also found that when I untick "Wrap" it works as expected on a single file in the Editor, but when using All Files, the unticked Wrap setting is ignored and it wraps around to the start of the book and replaces unwanted instances and I end up with, as an example, <em><em>some word</em></em> which means an additional S&R to clear that out.
Karellen is offline   Reply With Quote
Old 11-10-2021, 12:35 AM   #15
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,907
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
Quote:
Originally Posted by Karellen View Post
Ahh, I was careless with my proof reading. Let me fix my post so it reads what I intended.

What I meant to say is:

I have also found that when I untick "Wrap" it works as expected on a single file in the Editor, but when using All Files, the unticked Wrap setting is ignored and it wraps around to the start of the book and replaces unwanted instances and I end up with, as an example, <em><em>some word</em></em> which means an additional S&R to clear that out.
Is this with a "Replace all" or "Replace and Find"? Just tried both with the wrap turned off. Repeatedly using "Replace and Find" stopped after it made the change in the last file in the book and didn't go back to the beginning of the book. "Replace all" does what is says and replaced all instances no matter were they are. Is that the problem? If it is, I hadn't even thought of it being wrong. To me it is correct. I have been caught by it when making a change. Test it on a couple and then do replace all and if the already changed one match, I get what you are seeing. To me that's expected and I handle it. Normally by undoing the change on the test replaces so I can use replace all.
davidfor is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Regex Search Repetition doesn't work?! Wasserpulle Sigil 34 02-17-2018 02:49 PM
Regex Search doesn't search all files in Edit Book GregTheGrate Editor 8 11-08-2016 12:47 AM
Vers 7 CMD-V does not work into the search and replace fields GregTheGrate Sigil 25 04-22-2013 12:54 PM
Metadata Search & Replace - when it doesn't match Aldebaranian Library Management 4 09-28-2011 11:35 AM
Search & Replace doesn't work for quotes habanr Conversion 11 04-22-2011 11:50 AM


All times are GMT -4. The time now is 06:36 PM.


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