|
|
#1 |
|
Fanatic
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 511
Karma: 65460
Join Date: Jun 2011
Device: Kindle
|
Automate list not executing search/replace
I'm revising old CSS, and am trying to use the Automate List to replace old css with the new. One such example is replacing:
Code:
hr {
border: 0;
background-color: #000000;
height: 4px;
width: 85%;
}
Code:
hr {
border: 0;
background-color: #000000;
height: 4px;
width: 85%;
}
hr.hrsep {
border: 0;
background-color: #000000;
height: 1px;
width: 4em;
margin-top: 0.75em;
margin-bottom: 0.75em;
}
But other similar searches DO work... for example replacing Code:
.calibre {[\s.\w\p{P}]+?
}
Code:
.calibre {
display: block;
font-family: serif;
font-size: 1em;
line-height: 1.1;
margin-bottom: 0;
margin-left: 2pt;
margin-right: 2pt;
margin-top: 0;
padding-left: 0;
padding-right: 0;
page-break-before: always;
text-align: justify;
}
p {
display: block;
margin-top: 0;
margin-bottom: 0;
margin-left: 0;
margin-right: 0;
line-height: 1.15em;
}
Last edited by ElMiko; 11-20-2025 at 09:14 AM. |
|
|
|
|
|
#2 |
|
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 9,089
Karma: 6379704
Join Date: Nov 2009
Device: many
|
The automate function runs specific named saved searches. So please show the exact named source in a screencap from your Saved Searches Editor including all the control fields, and of course the exact find and replace fields as well. Then show the automation log, and finally your automation list itself.
Have you tried using all css or selected CSS files in your controls? If your control target is "current file", then the wrap control should probably be set as well given starting cursor position in the current file matters if that is determined by something earlier in the automation list. But depending on your find field value, and because it is really an append you are doing and not a replace (the find target will always exist even after a replace) you may need to worry about an infinite loop. Have you tried modifying the replace so that it modifies the code the find looks for to eliminate a loop? Or are you not using wrap? If not, how are you positioning the cursor in current file mode before running the automation list? Does your automation list run a saved search group or just a single saved search? Using "selected css" as the target (or "all css") would probably be better than current file as they always starts each file at the top automatically for sequential named searches. Last edited by KevinH; 11-20-2025 at 12:06 PM. |
|
|
|
|
|
#3 |
|
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 9,089
Karma: 6379704
Join Date: Nov 2009
Device: many
|
And as with any bug report, adding a simplified epub example file, a file including the sample searches (they can be exported in the Saved Search Editor), and your automation list would really help so that others can try to recreate what you are seeing.
FWIW, I never use the "current file" mode for searches in an automate list as current file mode needs proper cursor positioning and wrap mode to work reliably so just running a search manually, and running the saved search directly is probably a better idea and manually watching for the wrap overlap condition to occur. That is why I suggested the "All CSS" or "Selected CSS" mode above. |
|
|
|
|
|
#4 |
|
Fanatic
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 511
Karma: 65460
Join Date: Jun 2011
Device: Kindle
|
When I'm back at the computer tonight, I'll build a mock up file, and upload it along with the screenshots as well as the ini file for the group of searches and the automated list file.
Is there anything else that I should attach? |
|
|
|
|
|
#5 |
|
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 9,089
Karma: 6379704
Join Date: Nov 2009
Device: many
|
You can also export just selected saved searches using the SavedSearches context pop up menu. There is no need to send an entire ini file.
So epub with css file and a single html file, saved searches you use in automation list exported (as above), and a simplified automation list should be enough. But as I said, first I would try changing the saved search itself to use Selected CSS mode or All CSS files mode and *NOT* the Current File mode as the current file mode does not keep state (ie it is like the old stateless search) and in automation modes you need to use searches that keep state (which is the whole reason the change to search to keep state was made in the first place) especially when you are appending and not replacing with find and replace. Last edited by KevinH; 11-20-2025 at 02:25 PM. |
|
|
|
|
|
#6 |
|
Fanatic
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 511
Karma: 65460
Join Date: Jun 2011
Device: Kindle
|
Alright, here goes.
I tried the "All CSS" setting, and it didn't work. In fact, it return NO results unless I ran the automated list in the css file in question. As you can see in image AL_03, when it ran the list in a file other than the css file, despite having selected "All CSS", it ran the list as "All HTML", bizarrely. The other attached images are: AL_01: which shows that as a standalone search (i.e. not automated), the "CSS - hr" search does work (in "current file" mode or the key board shortcut for searching within the current file). AL_02: which is the log for the automated list when it is run with "Current file" selected and the css file open. The same result is displayed if you run it with "All CSS" (or its ilk), but ONLY if you have that file open in the viewing tab. Otherwise, as I said above, it yields NO matches. A couple of additional notes: 1) You will see that in AL_02, the second-to-last search—"CSS - copyright"—similarly had no matches or replacements. It is like the "CSS - hr" search in that it too will match when the search is run discreetly and in "Current file", but will fail when it's run as part of the automated list. 2) I have tried running the "CSS - hr" search (automated) with the following search term instead: Code:
hr {[\s.\w\p{P}]+?
}
3) I've attached the ini file (see note #4) for the group of searches in the automated list. Only the first, "manual CSS candidates", is irrelevant to the automation. 4) MobileReads doesn't like ini files, apparently, so I changed it to "CSSReplacements.txt" Please let me know if I've forgotten something, or some additional info is needed! Last edited by ElMiko; 11-20-2025 at 09:35 PM. |
|
|
|
|
|
#7 |
|
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 9,089
Karma: 6379704
Join Date: Nov 2009
Device: many
|
Your replacements file shows that your hr css search was done with the control value AH as target:
Code:
14\Name=CSS Replacements/CSS - hr
14\Find="hr {\n\tborder: 0;\n\tbackground-color: #000000;\n\theight: 4px;\n\twidth: 85%;\n\t}"
14\Replace="hr {\n\tborder: 0;\n\tbackground-color: #000000;\n\theight: 4px;\n\twidth: 85%;\n\t}\nhr.hrsep {\n\tborder: 0;\n\tbackground-color: #000000;\n\theight: 1px;\n\twidth: 4em;\n\tmargin-top: 0.75em;\n\tmargin-bottom: 0.75em;\n\t}"
14\Controls=RX WR DN AH
Please edit that search in your Search Editor and edit the Controls field and snap a screen shot of your target. Perhaps that Controls widget is broken somehow? If you select "All CSS" files the AC control should be set in your saved search not the AH. What appears after double clicking in that control field in the saved search editor and setting the target to All CSS files then clicking outside the controls to save it? Last edited by KevinH; 11-20-2025 at 10:36 PM. |
|
|
|
|
|
#8 | |
|
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 9,089
Karma: 6379704
Join Date: Nov 2009
Device: many
|
Furthermore once I edited it to select ALL CSS as the target ("AC") and run your automate list I get the following:
Quote:
As I said earlier. using "Currrent File" searches in an automation list is generally not a good idea unless you are sure you have set the initial cursor position properly (and that may be impossible in a automation list where the search is not done first) and are replacing the find field text (not just appending) so that only one pass is made even with wrap turned on. |
|
|
|
|
|
|
#9 | |
|
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 9,089
Karma: 6379704
Join Date: Nov 2009
Device: many
|
In fact when I use the Fill controls to "fix" your set of controls to use ALL CSS instead of Current File or All HTML, and run it I get the following log file:
Quote:
All appears to work. |
|
|
|
|
|
|
#10 | |
|
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 9,089
Karma: 6379704
Join Date: Nov 2009
Device: many
|
And, even if you leave it as "Current File" and after fixing the hr entry to use Current File too, it all seems to work as expected if you have open the styleesheets.css and turn on wrap and position the cursor near the top before launching the automate list.
It gives the following: Quote:
Perhaps the issue is tied to Windows somehow. As on a Mac I can not recreate what you are seeing. Last edited by KevinH; 11-20-2025 at 11:10 PM. |
|
|
|
|
|
|
#11 |
|
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 9,089
Karma: 6379704
Join Date: Nov 2009
Device: many
|
And fwiw, if you make a single search group to hold your searches, you can launch the entire search group in the search editor without any automation list at all in a single click.
|
|
|
|
|
|
#12 |
|
Fanatic
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 511
Karma: 65460
Join Date: Jun 2011
Device: Kindle
|
Oh my God. Okay. I had no idea what that column even meant. Part of the issue is that the majority of my searches have that column blank because Imported them from v 0.7.2....
This is HUGE. It also explains why it the automated list ended up running on "all HTML" for that last search... Last edited by ElMiko; 11-20-2025 at 11:58 PM. |
|
|
|
|
|
#13 |
|
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 9,089
Karma: 6379704
Join Date: Nov 2009
Device: many
|
Yes, when we changed search to keep its state and stop having to "watch for overlap nonsense", it made Saved Searches much more powerful. So we greatly extended the target list of files that a regex search could target again making it more useful for automation and regular usage.
So the number of settings we needed to save became larger when the search target list was expanded, so we added a "controls" field to the saved searches (and added a ui to set it all) to make saving and restoring theses targets/settings shorthand possible. That way the saved searches fully saved everything a user may have in their find and replace settings. |
|
|
|
![]() |
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| More than 3 Automate List functions | ElMiko | Sigil | 14 | 06-16-2025 09:48 PM |
| Search and Replace from a List | moldy | Editor | 37 | 03-27-2024 09:07 PM |
| Automate a page split... Find & Replace doesn't work for this | LostOnTheLine | Sigil | 24 | 11-28-2022 01:55 PM |
| Automate list and S&R | jmurphy | Sigil | 10 | 11-02-2022 08:47 AM |
| Regex in search problems (NOT Search&Replace; the search bar) | lairdb | Calibre | 3 | 03-15-2017 08:10 PM |