View Single Post
Old 08-11-2019, 09:30 PM   #2
Tex2002ans
Wizard
Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.
 
Posts: 2,306
Karma: 13057279
Join Date: Jul 2012
Device: Kobo Forma, Nook
Step 1: Open up the Find/Replace (Ctrl+F) or press the menu Search > Find & Replace.

Step 2: Make sure you have the Mode box set as Regex.

If you want to be safe, only have the Index open in Sigil, and change the 2nd dropdown to "Current File". This will make sure it won't go replacing through your entire book (although it shouldn't).

Step 3: Put this in the fields:

Search: <div class="sgc-index-entry">\s+(.+?)\s+(<a href="[^"]+">)\d+</a>\s+</div>
Replace: <div class="sgc-index-entry">\2\1</a></div>

What that will do is take your example code, and convert it into:

Code:
<div class="sgc-index-entry"><a href="link to the poem">first line of the poem</a></div>
It takes the link from around #1 and wraps it around the entry instead.

Alternate #3: Personally, what I would do is use:

Replace: <p class="indexfirstline">\2\1</a></p>

and adjust the CSS. The code would be much more readable.

Last edited by Tex2002ans; 08-11-2019 at 09:36 PM.
Tex2002ans is offline   Reply With Quote